Question: Consider the following solution for producer consumer problem: Prosucer While (TRUE){ item produce(); if (count == N) sleep(); lock (mutex); insert(item, buffer); count++; unlock

Consider the following solution for producer consumer problem: Prosucer While (TRUE){ item

 

Consider the following solution for producer consumer problem: Prosucer While (TRUE){ item produce(); if (count == N) sleep(); lock (mutex); insert(item, buffer); count++; unlock (mutex); if (count == 1) wakeup (consumer); 14 Consumer While (TRUE){ if (count == 0) sleep(); lock (mutex); item= remove (buffer); count --; unlock (mutex); if (count = N-1) wakeup (producer); consume (iten); Q1) (2 pts) What is the problem with this solution and under what conditions it happens? 2 Q2) (2 pts) Use semaphore to solve the synchronization for this problem.

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 Programming Questions!