• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | Gate IT 2008 | Question 51

The following is a code with two threads, producer and consumer, that can run in parallel. Further, S and Q are binary semaphores equipped with the standard P and V operations. semaphore S = 1, Q = 0; integer x; producer:                            consumer: while (true) do                    while (true) do P(S);                                      P(Q); x = produce ();                    consume (x); V(Q);                                     V(S); done                                       done Which of the following is TRUE about the program above?

(A)

The process can deadlock

(B)

One of the threads can starve

(C)

Some of the items produced by the producer may be lost

(D)

Values generated and stored in \'x\' by the producer will always be consumed before the producer can generate a new value

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