Assertion (A): In the bounded buffer problem, if a producer executes wait(mutex) followed by wait(empty), the system may deadlock.
Reason (R): The producer holds the mutex while blocked on the empty semaphore, preventing the consumer from entering the buffer to free a slot.
C
Step-by-Step Solution
Key idea: Acquiring a mutex before checking resource availability can lead to a circular wait if the resource is unavailable.
Step 1: The producer executes wait(mutex), setting mutex to 0 and acquiring the lock.
Step 2: The producer then executes wait(empty). If the buffer is full, empty is 0, so the producer blocks.
Step 3: The producer is now blocked while still holding the mutex.
Step 4: The consumer needs the mutex to remove an item and signal empty. Since the producer holds the mutex, the consumer blocks forever.
Step 5: Both processes are blocked, resulting in a deadlock. Thus, both A and R are true, and R correctly explains A.
Answer: C