GATE / CS ARCHIVE

SIMILAR QUESTIONS / OPERATING SYSTEMS

Diagnose strict alternation progress failure

2 questions solved the same way, newest first. Back to Operating Systems

How these are solved

Both use one shared turn variable to alternate two processes. Prove mutual exclusion from incompatible turn values, then show a process can be prevented from entering while its peer remains outside.

2 marks · MCQ
Report issue

Synchronization & Concurrency

Question 48, GATE 2016: Two processes share turn=0. Process 0 entry waits while turn==1, then executes its critical section and sets turn=1 on exit. Process 1 waits while turn==0, executes its critical section and sets turn=0 on exit. A correct solution; B violates mutual exclusion; C violates progress; D violates bounded waiting.
Tap to enlarge
Your answer
Answer & solution

Official answer: C

This is strict alternation. If process 0 finishes its critical section and remains in its remainder section, turn becomes 1. Process1 may enter and leave, setting turn back 0. A further request by process 1 is then blocked even though process 0 is not competing. This violates progress. Mutual exclusion holds because turn cannot be both 0 and 1; the intended answer is C under the standard synchronization-property definitions.

An even simpler progress witness occurs initially: only process 1 requests entry while process 0 stays forever in its remainder section. turn remains 0, so the empty critical section is inaccessible to the sole interested process. Strict alternation limits overtaking but lets an uninterested process prevent entry, which is why mutual exclusion alone is insufficient.

Original paper, page 40 · Answer key

1 mark · MCQ
Report issue

Boolean-turn mutual exclusion

Synchronization & Concurrency

Question 23, GATE 2010: Processes P1 and P2 use shared Boolean variables S1,S2 whose initial values are assigned randomly. Whenever they need their critical sections they execute:
P1: while (S1==S2); critical section; S1=S2;
P2: while (S1!=S2); critical section; S2=not(S1);
Which properties are achieved?
Options: (A) Mutual exclusion but not progress; (B) Progress but not mutual exclusion; (C) Neither mutual exclusion nor progress; (D) Both mutual exclusion and progress.
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

P1 passes its guard only when S1≠S2; P2 passes only when S1=S2. Neither changes the shared state until leaving its critical section, so while one is inside the other’s guard stays blocking: mutual exclusion holds. Progress fails: if S1=S2 and only P1 wants to enter, P1 spins forever unless P2 participates and changes S2. The symmetric case also occurs. This is strict alternation, so A, assuming atomic sequentially consistent accesses as the pseudocode model does.

After P1 exits it sets S1=S2, making P2 eligible and itself ineligible; after P2 exits it makes S2 the opposite of S1, restoring P1’s turn. Consequently the processes alternate even if one no longer wants the critical section. Mutual exclusion is a safety property; progress additionally requires that an uninterested process not prevent an interested one from entering.

Original paper, page 5