Home » Operating Systems » Operating systems miscellaneous » Question

Operating systems miscellaneous

  1. Consider the procedure below for the Producer-Consumer problem which uses semaphores :
    semaphore n = 0;
    semaphore s = 1;

    Which one of the following is TRUE ?
    1. The producer will be able to add an item to the buffer, but the consumer can never consume it.
    2. The consumer will remove no more than one item from the buffer.
    3. Deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.
    4. The starting value for the semaphore n must be 1 and not 0 for deadlock-free operation.
Correct Option: C

Consumer executes wait (S), then wait (n) and goes to sleep by decreasing n value.
After the consumer sleep, producer goes to the sleep by executing wait (s).
Dead lock occurs if the consumers succeeds in aquiring semaphore S when the buffer is empty.



Your comments will be displayed only after manual approval.