• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

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 intial 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

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments