Consider the following two-process synchronization solution. Process 0…

2016

Consider the following two-process synchronization solution.

Process 0
---------
Entry: loop while (turn == 1);
(critical section)
Exit: turn = 1;

Process 1
----------
Entry: loop while (turn == 0);
(critical section)
Exit: turn = 0;

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.

  4. D.

    This solution violates bounded wait requirement.

Attempted by 354 students.

Show answer & explanation

Correct answer: C

Key insight: the algorithm implements strict alternation using the shared variable turn.

  • Mutual exclusion: satisfied. When turn == 0 only the first process can pass its entry loop; when turn == 1 only the second process can. Both cannot be in the critical section simultaneously.

  • Progress: violated. If it is the other process's turn but that process is not interested in entering, a process that does want to enter is forced to wait even though the critical section is free. For example, after the first process exits it sets turn = 1; if the first process then wants to reenter but the second process does not wish to enter, the first process will busy-wait until the second process changes turn, so the system can be blocked from making progress.

  • Bounded waiting: satisfied. The scheme guarantees a fixed bound (at most one entry by the other process) before a waiting process gets the turn back, so waiting cannot be unbounded.

Conclusion: The algorithm fails the progress requirement (strict alternation can block a ready process while the other inactive process holds the 'turn'), so the correct statement is that the solution violates progress.

A video solution is available for this question — log in and enroll to watch it.

Explore the full course: Gate Guidance By Sanchit Sir