GateAI
Concurrency and Synchronization

GATE CSE 2016 Set 2 · Q49

NAT2 marksMedium

Time

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, 20 P(S)P(S) operations and 12 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 __________.

Your answerNumerical answer

Enter a value to check

Solution

Step-by-step verified solution

Official answer: 7 (±0)

Concurrency and Synchronization

Let S0S_0 be the initial non-negative value of the counting semaphore SS.

  • Each successful P(S)P(S) (wait) operation consumes 11 permit from the semaphore.

  • Each V(S)V(S) (signal) operation adds 11 permit to the semaphore.

  • Total P(S)P(S) operations issued = 2020.

  • Total V(S)V(S) operations issued = 1212.

The maximum possible number of permits available across the entire execution (even under the most favorable ordering where all 1212 V(S)V(S) operations execute before blocked P(S)P(S) operations) is:

Total permits=S0+12\text{Total permits} = S_0 + 12

For at least one P(S)P(S) operation to remain blocked, the total available permits must not be enough to satisfy all 2020 P(S)P(S) operations:

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

Since S0S_0 must be an integer, the largest possible initial value is:

S0=7S_0 = 7

With S0=7S_0 = 7, at most 7+12=197 + 12 = 19 P(S)P(S) operations can succeed, guaranteeing that at least 11 P(S)P(S) operation remains blocked [CS-2, Q49].

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Concurrency and Synchronization previous year question is Q49 of the GATE CSE 2016 Set 2 paper. Find more GATE CSE PYQs on Concurrency and Synchronization in Operating Systems, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Concurrency and Synchronization PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Concurrency and Synchronization in GATE CSE

Concurrency and Synchronization has 18 GATE CSE PYQs across 15 papers from 2012 to 2026. This is the only 2-mark NAT question among them, and GATE CSE 2016 Set 2 has 2.

How GATE tests Concurrency and Synchronization

More from GATE CSE 2016 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2016 Set 2 · Q49 · NAT

Consider a non-negative counting semaphore S. The operation P(S) decrements S, and V(S) increments S. During an execution, 20 P(S) operations and 12 V(S) operations are issued in some order. The largest initial value of S for which at least one P(S) operation will remain blocked is …

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.