Question discussion

In the bounded-buffer problem with semaphores mutex = 1, empty = N and full = 0, which change to the producer's code can lead to deadlock?

1579Medium DSSSB TGT Computer Science 0 replies

In the bounded-buffer problem with semaphores mutex = 1, empty = N and full = 0, which change to the producer's code can lead to deadlock?

  • AExecuting wait(empty) before wait(mutex)
  • BExecuting wait(mutex) before wait(empty)
  • CExecuting signal(mutex) before signal(full)
  • DExecuting signal(full) before signal(mutex)
Correct answer: B

Explanation

If the producer takes the mutex first and then blocks on empty because the buffer is full, the consumer can never enter its critical section to free a slot, so both wait forever.

Discussion 0

Nobody has replied yet. Start the discussion!