Skip to content
Official PYQ · 1992

GATE CS 1992 Q02 — Concurrency and Synchronization

Explain with AI

At a particular time of computation, the value of a counting semaphore is 77. Then 2020 PP operations and 1515 VV operations were completed on this semaphore. The resulting value of the semaphore is :

Choose one option
View worked solution

Answer: B

A counting semaphore SS is an integer variable that is modified by two standard atomic operations: PP (wait) and VV (signal).

  • PP operation: Decrements the semaphore value by 11 (S=S−1S = S - 1).
  • VV operation: Increments the semaphore value by 11 (S=S+1S = S + 1).

Given:

  • Initial value of the semaphore, Sinitial=7S_{\text{initial}} = 7
  • Number of PP operations = 2020
  • Number of VV operations = 1515

We can calculate the final value of the semaphore as follows:

Sfinal=Sinitial−(Number of P operations)+(Number of V operations)S_{\text{final}} = S_{\text{initial}} - (\text{Number of } P \text{ operations}) + (\text{Number of } V \text{ operations}) Sfinal=7−20+15=2S_{\text{final}} = 7 - 20 + 15 = 2

Thus, the resulting value of the semaphore is 22, which corresponds to option B.

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

Published
Report a correction
Keep exploringMore Concurrency and Synchronization questions