Skip to content
Related Articles

Related Articles

GATE | GATE-CS-2016 (Set 2) | Question 58
  • Last Updated : 16 Apr, 2018

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; 

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)

Explanation: A mutual exclusive requirement prevents simultaneous access to a shared resource. Since, semaphore turn is initialized to zero and this semaphore value is changing only after critical section for given processes. So, this ensures at most one process in the critical section at a time, i.e., mutual exclusive requirement is satisfied.

Progress means that process should eventually be able to complete. But directly Process 1 can not go critical section as semaphore value is 0 initially and this process 1 can go CS only after process 0. So, progress requirement is not satisfied.

Bounded waiting means no process should wait for a resource for infinite amount of time. Process 1 can go directly and Process 1 can go after process 0 into critical section. So, Bounded waiting is satisfied.

Option (C) is correct.

Quiz of this Question


My Personal Notes arrow_drop_up
Recommended Articles
Page :