GATE / CS ARCHIVE

GATE CSE 2016 SET 2 / QUESTION 49

GATE CSE 2016 Set 2 Q49

Operating Systems · Synchronization & Concurrency · Full GATE CSE 2016 Set 2 paper

GATE 2016 Set 2, Q49 2 marks · NAT
Report issue

Synchronization & Concurrency

Question 49, GATE 2016: A nonnegative counting semaphore S uses P to decrement when permitted and V to increment. Twenty P and twelve V operations are issued in some order. Find the greatest initial S for which at least one P remains blocked after the V operations are processed.
Tap to enlarge
Answer & solution

Official answer: 7.0 : 7.0

Our answer: 7

After all 12 V operations have taken effect, the total number of permits available to satisfy the 20 P operations is S0+12. At least one remains blocked exactly when S0+12<20, giving the largest integer S0=7. This concerns operations remaining blocked after all issued V operations are processed, not a temporary block earlier in some ordering.

At S0=7 there are only 19 permits over the entire execution, so twenty P operations cannot all finish. At S0=8 there are twenty permits, enough eventually to release every issued P once all twelve V operations occur. A transient empty semaphore does not prove an operation will remain blocked after future signals.

Original paper, page 40 · Answer key