Consider the following solution to the producer-consumer synchronization problem

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

Take Mock Tests

Government Schemes Mock Test Start Test!
Political Science Mock Test โ€“ 42 Start Test
History Test โ€“ 190 Start Test
Quantitative Aptitude Test Start Test!
Data Interpretation - Mock Test Start Test!
General Awareness - Mock Test Start Test!
Reasoning Ability - Mock Test Start Test!
We will be happy to hear your thoughts

Leave a reply

Gkseries.com
Logo
Register New Account