Skip to main content

GATE CSE 2010Operating System › Process Synchronization & ConcurrencyVerified

GATE CSE 2010 PYQ: Consider the methods used by processes P 1 P1 P 1 and P 2 P2 P 2 for accessing their critical sections…

Consider the methods used by processes P1P1 and P2P2 for accessing their critical sections whenever needed, as given below. The initial values of shared boolean variables S1S1 and S2S2 are randomly assigned.
Method used by P1Method used by P2while (S1 == S2);while (S1 != S2);Critical SectionCritical SectionS1 = S2;S2 = not(S1);\begin{array}{|l|l|}\hline \textbf{Method used by P1} & \textbf{Method used by P2} \\ \hline \text{while (S1 == S2);} & \text{while (S1 != S2);} \\ \text{Critical Section} & \text{Critical Section} \\ \text{S1 = S2;} & \text{S2 = not(S1);} \\\hline \end{array}
Which one of the following statements describes the properties achieved?

  1. A
    Mutual exclusion but not progress
    Correct answer
  2. B
    Progress but not mutual exclusion
  3. C
    Neither mutual exclusion nor progress
  4. D
    Both mutual exclusion and progress

Answer

(A) Mutual exclusion but not progress

Approach

Treat the two shared booleans as encoding a turn. The key is to identify exactly when each process can leave its busy-wait loop. P1 enters only when S1 != S2, and P2 enters only when S1 == S2. These conditions are complementary, so at most one process can enter the critical section. However, after leaving the CS, each process flips the variables so that the turn passes to the other process. This is strict alternation: if the other process is not interested, the interested process can remain blocked forever, violating progress.

The two entry conditions are complementary, so mutual exclusion is guaranteed. But the post-critical-section assignments make the processes alternate strictly. If the process whose turn it is does not want to enter, the other process cannot proceed even though the critical section is free. Hence progress is violated. The correct option is A.

Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.