3i Infotech Papers: Sample Questions 375 - 376 of 1245

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

Question number: 375

» Languages » C & C Plus Plus

Short Answer Question▾

Write in Short

What is the output of the following program?

  1. struct point{int x;int y;};struct point origin,*pp;main(){pp=&origin;printf("origin is(%d%d) ",(*pp).x,(*pp).y);printf("origin is (%d%d) ",pp->x,pp->y);}


  • In the program

    Table shows the program

    Table shows the program

    int x; int y;

    Structure pointer is globally declared with x and y.


    pp is a pointer to structure.

    printf (“origin is (%d % d) ”, (*pp). x, (*pp). y); printf (“origin is (%d % d) ”, pp- > x, pp- > y);

    We can access the elements ofthe structure either with arrow mark or with indirection operator.

    Since structure point is globally declared x & y are initialized as zeroes

  • So, the answer is origin is (0,0) origin is (0,0).

Question number: 376

» Basic CS » Operating System

Essay Question▾

Describe in Detail

What is context switching?


Understanding of context switching

Understanding of Context Switching

Understanding of context switching

  • Switching of the CPU from one process or thread to another.

  • Context switch describes a standard procedure followed to “switch” from one task to another.

  • Ensures that the tasks do not conflict- they are given their separate contexts.

  • Critical for providing user-friendly multitasking.

  • Performed entirely in hardware.

  • Allows numerous processes or threads on a single processor.

  • Stores and restores the state of CPU in Process Control block- process execution resumes from the same point at a later time.

Three situations of context switch:

  • Multitasking

    • The CPU needs to switch processes in and out of memory.

    • So, more than one process can be running.

  • Kernel/User Switch

    • Switching between user mode to kernel mode.

  • Interrupts

    • When the CPU is interrupted to return data from a disk read.

Three situations of context switch

Three Situations of Context Switch

Three situations of context switch