CS FundamentalsHardGATE CS

Strict alternation uses a shared turn variable: P0: `while (turn != 0); CS; turn = 1;` P1: `while (turn != 1); CS; turn = 0;`. P0 wants to enter its critical section twice in a row while P1 is busy in a long remainder section. What happens?

  1. A. P0 enters twice; mutual exclusion is violated
  2. B. Both deadlock immediately
  3. C. P0 blocks after its first entry until P1 enters and leaves its own critical section, violating progress
  4. D. P0 enters twice with no waiting

Correct answer: C. P0 blocks after its first entry until P1 enters and leaves its own critical section, violating progress

After P0 sets turn = 1, only P1 may enter next. P1, not interested, holds up P0 from its remainder section: this violates progress, though mutual exclusion holds.

More Operating Systems questions

Exams that ask this topic