1.

Consider the procedure below for the Producer-Consumer problem which uses Semaphores and choose the correct statement:semaphore n = 0;semaphore s = 1;// Producer Functionvoid producer(){while(true){produce();semWait(s);addToBuffer();semSignal(s);semSignal(n);}}// Consumer functionvoid consumer(){while(true){semWait(s);semWait(n);removeFromBuffer();semSignal(s);consume();}}(A) The producer will be able to add an item to the buffer, but the consumer can never consume it.(B) The consumer will remove no more than one item from the buffer.(C) Deadlock occurs if the consumer succeeds in acquiring semaphore s when the buffer is empty.(D) The starting value for the semaphore n must be 1 and not 0 for deadlock-free operation.

Answer»


Discussion

No Comment Found

Related InterviewSolutions