Consider the following solution to the producer-consumer synchronization problem

Consider the following solution to the producer-consumer synchronization problem. The shared buffer size is ๐‘

Q. 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?

A. P: full,ย ย ย ย ย  Q: full,ย ย ย ย  R: empty, S: empty

B. P: empty, Q: empty, R: full,ย ย ย ย  S: full

C. P: full,ย ย ย ย ย  Q: empty, R: empty, S: full

D. P: empty, Q: full,ย ย ย ย ย  R: full,ย ย ย ย ย  S: empty

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

Gkseries: Gkseries.com is a premier website to provide complete solution for online preparation of different competitive exams like UPSC, SBI PO, SBI clerical, PCS, IPS, IAS, IBPS PO, IBPS Clerical exam etc. & other graduate and post-graduate exams. Learn more on about us page