Consider the following solution to the producer-consumer synchronization…

GATE · 2018 · CS · Computer Science & IT

Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is 𝑁. Three semaphores empty, full and mutex are defined with respective initial values of 0, 𝑁 and 1. Semaphore empty denotes the number of available slots in the buffer, for the consumer to read from. Semaphore full denotes the number of available slots in the buffer, for the producer to write to. The placeholder variables, denoted by P, Q, R, and S, in the code below can be assigned either empty or full. The valid semaphore operations are: wait() and signal().

Which one of the following assignments to P, Q, R and S will yield the correct solution?

  1. A.

    P: full, Q: full, R: empty, S: empty

  2. B.

    P: empty, Q: empty, R: full, S: full

  3. C.

    P: full, Q: empty, R: empty, S: full

  4. D.

    P: empty, Q: full, R: full, S: empty

Attempted by 259 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…