• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | GATE-IT-2004 | Question 65

The semaphore variables full, empty and mutex are initialized to 0, n and 1, respectively. Process P1 repeatedly adds one item at a time to a buffer of size n, and process Prepeatedly removes one item at a time from the same buffer using the programs given below. In the programs, K, L, M and N are unspecified statements.
 P1
while (1) {     K; P(mutex); Add an item to the buffer; V(mutex);     L; } P2 while (1) {    M; P(mutex); Remove an item from the buffer; V(mutex);     N; } The statements K, L, M and N are respectively

(A)

P(full), V(empty), P(full), V(empty)

(B)

P(full), V(empty), P(empty), V(full)

(C)

P(empty), V(full), P(empty), V(full)

(D)

P(empty), V(full), P(full), V(empty)

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