GATE CS 2022 | Question 19

Operating Systems › Process Synchronization · MCQ · 1 mark · Answer: C

  1. Question 19Operating Systemsmcq1 mark
    Threads T1 (wait S3; print "C"; signal S2), T2 (wait S1; print "B"; signal S3), T3 (wait S2; print "A"; signal S1), each in a while(true) loop. Which initialization prints BCABCA...?
    • A.
      S1 = 1; S2 = 1; S3 = 1
    • B.
      S1 = 1; S2 = 1; S3 = 0
    • C.
      S1 = 1; S2 = 0; S3 = 0
      ✓
    • D.
      S1 = 0; S2 = 1; S3 = 1

    Answer: C

    Solution

    Answer: (C) S1 = 1; S2 = 0; S3 = 0 To print B first, T2 must run first, so S1=1 (and S2=S3=0 to block T3, T1 initially). T2 prints B, signals S3 -> T1 prints C, signals S2 -> T3 prints A, signals S1 -> T2 again... producing B,C,A,B,C,A,... So S1=1, S2=0, S3=0.

More GATE PYQ on Process Synchronization

All GATE CS Operating Systems PYQ →

Attempt GATE CS 2022 in real GATE exam mode

Full paper with a timer, the GATE interface and a topic-wise analysis — free.

Create free account →