Machine-translated by Google. Questions are authored in English.
Top

Discussion

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?

  • A.This is a correct two-process synchronization solution.
  • B.This solution violates mutual exclusion requirement.
  • C.This solution violates progress requirement.
  • D.This solution violates bounded wait requirement.

Answer: C

The solution violates the progress requirement.

This is strict alternation. Mutual exclusion holds: turn is either 0 or 1, and each process can enter only when turn has its own value, so both can never be inside together. Bounded waiting also holds, because after a process leaves it hands the turn to the other, so neither can enter twice while the other waits.

Progress fails. Suppose Process 0 runs its critical section and sets turn = 1, and Process 1 has no wish to enter. If Process 0 now wants to enter again, it must wait for Process 1 to take its turn, which may never happen. A process outside its critical section is blocking another from entering, which is exactly what the progress requirement forbids.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.