Question: uestion # Consider the following solution for the bounded-buffer producer-consumer problem. One requirement is that the producer must print when the buffer is full and

 uestion # Consider the following solution for the bounded-buffer producer-consumer problem.

uestion # Consider the following solution for the bounded-buffer producer-consumer problem. One requirement is that the producer must print when the buffer is full and the consumer must print when the buffer is empty semaphore mutex 1; semaphore empty N; semaphore full 0; int inp outp 0; Code for Producer process Code for Consumer process produce (item); wait (empty); wait (mutex); Buffer[inp] item; inp (inp + 1) % N; signal (mutex); signal (full); wait (full); wait (mutex); item Buffer [outp]; out: (outp + 1) % N; signal (mutex); signal (empty); if (empty N) if (full N) printf (Buffer is empty "); consume (item printf ("Buffer is full "); while (True) while (True) N is the buffer size. There is at least one serious bug (non-syntactic) in the above program. a) Find out all the bugs and describe what problems they can cause b) Fix all the bugs and rewrite the program. In your solution, the producer must print when the buffer is full and the consumer must print when the buffer is empty

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!