GATE / CS ARCHIVE

GATE CSE 2010 / QUESTION 23

Boolean-turn mutual exclusion

Operating Systems · Synchronization & Concurrency · Full GATE CSE 2010 paper

GATE 2010, Q23 1 mark · MCQ
Report issue

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