Skip to content
Official PYQ · 2016

GATE CS 2016 Set 2 Q49 — Concurrency and Synchronization

Explain with AI
Consider a non-negative counting semaphore SS. The operation P(S)P(S) decrements SS, and V(S)V(S) increments SS. During an execution, 2020 P(S)P(S) operations and 1212 V(S)V(S) operations are issued in some order. The largest initial value of SS for which at least one P(S)P(S) operation will remain blocked is _______
View worked solution

Answer: 7

To find the largest initial value of the counting semaphore SS (let it be S0S_0) for which at least one P(S)P(S) operation remains blocked at the end of the execution:

  • Each P(S)P(S) operation decrements the semaphore and requires 11 resource unit. Total P(S)P(S) operations = 2020.
  • Each V(S)V(S) operation increments the semaphore and releases 11 resource unit. Total V(S)V(S) operations = 1212.

The total number of resource units available during the entire execution is the sum of the initial value and the units released by V(S)V(S) operations:

Total Available Resources=S0+12\text{Total Available Resources} = S_0 + 12

For at least one P(S)P(S) operation to remain blocked at the end, the total available resources must be strictly less than the total number of requested P(S)P(S) operations:

S0+12<20  ⟹  S0<8S_0 + 12 < 20 \implies S_0 < 8

Thus, the largest integer value of S0S_0 is 77.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Concurrency and Synchronization questions