GATEverse
← GATE CSE 2004

Q48

MCQ2 marks, −0.5

Consider two processes P1P_1 and P2P_2 accessing the shared variables XX and YY protected by two binary semaphores SXS_X and SYS_Y respectively, both initialized to 1. PP and VV denote the usual semaphore operators, where PP decrements the semaphore value, and VV increments the semaphore value. The pseudo-code of P1P_1 and P2P_2 is as follows:

P1:P2:While true do {While true do {L1:……L3:……L2:……L4:……X = X + 1;Y = Y + 1;Y=Y−1;X=Y−1;V(SX);V(SY);V(SY);V(SX);}}\begin{array}{|l|l|} \hline P_1: & P_2: \\ \hline \text{While true do \{} & \text{While true do \{} \\ L_1:\dots\dots & L_3:\dots\dots \\ L_2:\dots\dots & L_4:\dots\dots \\ \text{X = X + 1;} & \text{Y = Y + 1;} \\ Y = Y - 1; & X = Y - 1; \\ V(S_X); & V(S_Y); \\ V(S_Y); & V(S_X); \\ \} & \} \\ \hline \end{array}

In order to avoid deadlock, the correct operators at L1L_1, L2L_2, L3L_3 and L4L_4 are respectively.

Sign in to save attempts.

Loading…