GATEverse
← GATE CSE 2022

Q9

MCQ1 mark, −0.33

Consider the following threads, T1,T2,\text{T}_{1}, \text{T}_{2}, and T3\text{T}_{3} executing on a single processor, synchronized using three binary semaphore variables, S1,S2,\text{S}_{1}, \text{S}_{2}, and S3,\text{S}_{3}, operated upon using standard wait()\textsf{wait}() and signal().\textsf{signal}(). The threads can be context switched in any order and at any time.

T1T2T3while(true){while(true){while(true){wait(S3);wait(S1);wait(S2);print(“C”);print(“B”);print(“A”);signal(S2);}signal(S3);}signal(S1);}\begin{array}{|c|c|c|} \hline \text{T}_{1} & \text{T}_{2} & \text{T}_{3} \\\hline \text{while(true)} \{ & \text{while(true)} \{& \text{while(true)} \{ \\ \text{wait(S}_{3}); & \text{wait(S}_{1}); & \text{wait(S}_{2}); \\ \text{print(“C”)}; & \text{print(“B”)}; & \text{print(“A”)}; \\ \text{signal(S}_{2}); \} & \text{signal(S}_{3}); \} & \text{signal(S}_{1}); \} \\\hline \end{array}

Which initialization of the semaphores would print the sequence BCABCABCA…?\text{BCABCABCA} \dots ?

Sign in to save attempts.

Loading…