GATE CS 2022 · Question 19 · Operating System · Multiple choice (MCQ) · 1 mark · −1/3 for a wrong answer

Consider the following threads, T₁, T₂, and T₃ executing on a single processor, synchronized using three binary semaphore variables, S₁, S₂, and S₃, operated upon using standard wait() and signal(). The threads can be context switched in any order and at any time.
T₁:
while(true){ wait(S3); print("C"); signal(S2); }
T₂:
while(true){ wait(S1); print("B"); signal(S3); }
T₃:
while(true){ wait(S2); print("A"); signal(S1); }
Which initialization of the semaphores would print the sequence BCABCABCA…?

  1. (A) S₁ = 1; S₂ = 1; S₃ = 1
  2. (B) S₁ = 1; S₂ = 1; S₃ = 0
  3. (C) S₁ = 1; S₂ = 0; S₃ = 0
  4. (D) S₁ = 0; S₂ = 1; S₃ = 1
Answer

Answer (C)

Answer from the official GATE CS 2022 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes