Processes P1 and P2 have a producer-consumer relationship, communicating by…
2018
Processes P1 and P2 have a producer-consumer relationship, communicating by the use of a set of shared buffers.
P1: repeat
Obtain an empty buffer
Fill it
Return a full buffer
forever
P2: repeat
Obtain a full buffer
Empty it
Return an empty buffer
foreverIncreasing the number of buffers is likely to do which of the following?
I. Increase the rate at which requests are satisfied (throughput)
II. Decrease the likelihood of deadlock
III. Increase the ease of achieving a correct implementation
- A.
III only
- B.
II only
- C.
I only
- D.
II and III only
Attempted by 23 students.
Show answer & explanation
Correct answer: C
Concept
In a bounded-buffer producer-consumer system, buffer capacity and synchronization correctness are governed by different mechanisms. The number of buffer slots only sets how much a producer can get ahead of a consumer (or vice versa) before one must wait - it does not change the semaphore protocol (mutex, empty, full) that a correct implementation needs, and it does not change the order in which those semaphores are acquired, which is what determines whether the solution is deadlock-free.
Applying it to each statement
Statement I (throughput): with more buffer slots, P1 can fill several buffers before it must wait for P2 to empty one, and P2 can empty several before waiting on P1 - so both processes block on each other less often. Fewer blocking waits per unit time means more fill or empty operations complete in the same time, so throughput increases. This statement is TRUE.
Statement II (deadlock): deadlock here would come from an incorrect order of acquiring the mutex and the empty or full semaphores (for example, holding mutex while blocked on empty or full). That ordering is a property of how the code is written, not of how many buffers exist - the same flawed order deadlocks whether there is one buffer or a thousand. This statement is FALSE.
Statement III (ease of implementation): a correct solution still needs exactly the same three synchronization primitives (mutex, empty-count, full-count) and the same wait or signal pairing regardless of buffer count - adding slots changes only the initial value of a counting semaphore, not the reasoning required to get the logic right. This statement is FALSE.
Cross-check
Consider the two extremes: a correctly-synchronized implementation with a single buffer is deadlock-free, and a correctly-synchronized implementation with many buffers is also deadlock-free - capacity did not change that outcome, only the rate of progress changed. Conversely, an incorrectly-ordered implementation can deadlock at any buffer count. This confirms only the throughput claim (Statement I) tracks with buffer count.
Hence only Statement I follows from increasing the number of buffers, matching the saved key of I only.
A video solution is available for this question — log in and enroll to watch it.