Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2026 Set 2
Questions

Q41

MSQ2 marksOperating systems

Consider three processes P1, P2\text{P1, P2}, and P3\text{P3} running identical code, as shown in the pseudocode below. A\text{A} and B\text{B} are two binary semaphores initialized to 11 and 00, respectively. X\text{X} is a shared variable initialized to 00. Each line in the pseudocode is executed atomically. Pseudocode of P1, P2, and P3

Wait(A);
Print(*);
X = X+1;
If (X == 2)
{
    Print($);
    Signal(B);
}
Signal(A);
Wait(B);
Print(#);
Signal(B);

Assume that any of the three processes can start to execute first and context switching can happen between these processes at any arbitrary time and in any arbitrary order. Which of the following patterns is/are possible to be generated as an outcome of the execution of these three processes?

Sign in to save attempts.

The solution is hidden while you attempt this question. It opens once you check or show the answer.