CS FundamentalsHardProduct-company MCQ pattern

Two processes use this code for mutual exclusion; turn is shared and starts at 0. Which property does it FAIL?

Two processes use this code for mutual exclusion; `turn` is shared and starts at 0. Which property does it FAIL?
// Process i (i = 0 or 1)
while (true) {
    while (turn != i) ;   // busy wait
    /* critical section */
    turn = 1 - i;
    /* remainder section */
}
  1. A. It satisfies all three requirements
  2. B. Both mutual exclusion and bounded waiting
  3. C. Mutual exclusion
  4. D. Progress

Correct answer: D. Progress

Strict alternation guarantees mutual exclusion and bounded waiting, but if process 0 wants to enter twice in a row while process 1 stays in its remainder section, process 0 is blocked by a process not interested in entering. That violates progress. Peterson's algorithm fixes it with flag[].

More Operating Systems questions

Exams that ask this topic