Skip to content
Official PYQ · 1998

GATE CS 1998 Q1.31 — Concurrency and Synchronization

Explain with AI

A counting semaphore was initialized to 1010. Then 6P6 P (wait) operations and 4V4V (signal) 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 accessed through two standard atomic operations: PP (wait) and VV (signal).

  • Initial value of the semaphore: Sinit=10S_{\text{init}} = 10
  • PP (wait) operation: Decrements the semaphore value by 11 (S←S−1S \leftarrow S - 1).
  • VV (signal) operation: Increments the semaphore value by 11 (S←S+1S \leftarrow S + 1).

After performing 66 PP operations and 44 VV operations, the final value of the semaphore is calculated as:

Sfinal=Sinit−(Number of P operations)+(Number of V operations)S_{\text{final}} = S_{\text{init}} - (\text{Number of } P \text{ operations}) + (\text{Number of } V \text{ operations})Sfinal=10−6+4=8S_{\text{final}} = 10 - 6 + 4 = 8

Thus, the resulting value of the semaphore is 8.

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

Published
Report a correction
Keep exploringMore Concurrency and Synchronization questions