Open In App

Algorithms Quiz | Sudo Placement : Set 1 | Question 8

Here are the two concurrent process P1, P2 with respective codes:
P1 code:

while (true) // infinite condition
{
A :____;
printf("%d", 1);
printf("%d", 1);
B:____;
}

P2 code:

while (true) // infinite condition
{
C:____;
printf("%d", 0);
printf("%d", 0);
D:____;
}

What should be the binary semaphore operation on A,B,C,D respectively and what must be the initial values of semaphore M,N inorder to get the output 110011001100….?
Where P is down and V is up operation respectively.
(A) A = P(N), B = V(M), C = P(M), D = V(N); M = 0, N = 1;
(B) A = P(N), B = V(M), C = P(M), D = P(N); M = N = 1;
(C) A = P(N), B = V(N), C = P(M), D = V(M); M = 1, N = 0;
(D) A = P(N), B = V(N), C = P(M), D = V(M); M = N = 1;

Answer: (A)
Explanation:
Quiz of this Question

Article Tags :