In the bounded-buffer producer-consumer problem, a buffer has N slots. Which initial semaphore values are conventionally used for empty slots, full slots and mutual exclusion, respectively?

Options

  • A. empty = 0, full = N, mutex = 1
  • B. empty = N, full = 0, mutex = 1
  • C. empty = 1, full = 1, mutex = N
  • D. More than one of the above
  • E. None of the above

Correct Answer (Detailed Explanation is Below)

B. empty = N, full = 0, mutex = 1

Detailed Explanation

Explanation: Initially, all N buffer slots are empty, so empty = N. No item is available for consumption, so full = 0. The mutex is initialized to 1 to provide mutual exclusion while accessing the shared buffer.