Question: For the following Producer-consumer Problem using Semaphores, (a) Will there be any deadlock if the order of the downs were switched, for the producer or
For the following Producer-consumer Problem using Semaphores, (a) Will there be any deadlock if the order of the downs were switched, for the producer or for the consumer individually as well as together (so, 3 combinations)? Explain. Now, (b) similarly consider the order of ups and show (3 combinations again) when you assume that the ups are switched then keep the downs intact (not switched). 
Producer-consumer Problem using Semaphores Here, the semaphores solve the lost-wakeup problem: semaphore mutex 1; /* binary semaphore providing mutual exclusion */ semaphore empty N; counting semaphore, counts empty buffer slots "/ semaphore full 0; counting semaphore, counts full buffer slots "/ void producer(void) void consumer(void) while(TRUE) while(TRUE) int item- produce_item); down(&empty); down(&mutex); // Enter CR insert-item( item): put in buffer up(&mutex); I/ Leave CR up(&full) down(&full); down(&mutex); // Enter CR int itemremove item(); remove em from bufer up(&mutex); // Leave CR up(&empty); consume item(item); // do something with it
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
