TCS Papers: Sample Questions 244 - 245 of 502

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 244

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Can we have a pointer to a function? Given an example.

Explanation

  • Yes we can have pointer to function, in following example, foo is a pointer to a function taking one argument, an integer, and that returns void.

  • Function called “*foo”, takes an int and returns void; now, if * foo is a function, then foo must be a pointer to a function.

  • Example:

  1. #include<stdio.h>
  2. void func(int a)
  3. {
  4.     printf("Hello");
  5. }
  6. void main()
  7. {
  8.     void (*fp)(int);
  9.     fp=func;
  10.     fp(1);
  11. }
  • Output:

Hello

Question number: 245

» Basic CS » Operating System

Essay Question▾

Describe in Detail

What is a trap and trapdoor?

Explanation

Trap: -

  • The execution of an instruction that intended for user programs and transfers control to the operating system.

  • Trap causes branch to OS code and a switch to kernel mode.

  • When in kernel mode, a trap handler is executed to service the request.

  • Restarted at the address following the address causing the trap.

  • Example: any System call.

Image of The Traps Example

Image of the Traps Example

Given the image is define the Traps example

Trapdoor: -

  • Secret undocumented entry point to the program.

  • An example of such feature is so called back door.

  • This enables intrusion to the target by passing user authentication methods.

  • A hole in the security of a system deliberately left in place by designers or maintainers.

  • Trapdoor allows unauthorized access to the system.

  • Only purpose of a trap door is to “bypass” internal controls.

  • It is up to the attacker to determine how this circumvention of control can be utilized for his benefit.

Image of The Trap door

Image of the Trap Door

Given the image is define the trap doors