Skip to main content

GATE CSE 2016Operating System › Process Synchronization & ConcurrencyVerified

GATE CSE 2016 PYQ: Consider the following two-process synchronization solution. PROCESS 0 Process 1 Entry: loop while (turn ==…

Consider the following two-process synchronization solution.
PROCESS 0 Process 1 Entry: loop while (turn == 1); Entry: loop while (turn == 0);(critical section) (critical section)Exit: turn = 1;Exit turn = 0; \begin{array}{|l|l|}\hline \text{PROCESS 0 } & \text{Process 1 }\\ \\ \text{Entry: loop while (turn == 1); } & \text{Entry: loop while (turn == 0);} \\ \quad\text{(critical section)} &\quad \text{ (critical section)} \\ \text{Exit: turn = 1;} & \text{Exit turn = 0; }\\ \\\hline \end{array}

The shared variable turn is initialized to zero. Which one of the following is TRUE?

  1. A
    This is a correct two- process synchronization solution.
  2. B
    This solution violates mutual exclusion requirement.
  3. C
    This solution violates progress requirement.
    Correct answer
  4. D
    This solution violates bounded wait requirement.

Answer

(C) This solution violates progress requirement.

Approach

Treat the shared variable turn as a token that decides which process may enter the critical section. Check the standard synchronization requirements: mutual exclusion, progress, and bounded waiting.

The algorithm enforces strict alternation using turn. It guarantees mutual exclusion and bounded waiting, but it violates progress because an uninterested process can prevent the other process from entering the critical section.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.