Question: Given the following code that solves the Producer - Consumer problem, complete the missing synchronization code statements in the given empty boxes Your code would

 Given the following code that solves the Producer - Consumer problem,
complete the missing synchronization code statements in the given empty boxes Your

Given the following code that solves the Producer - Consumer problem, complete the missing synchronization code statements in the given empty boxes Your code would allow a The producer to wait for the consumer to empty buffer iful The consumer to wait for the producer to til the butter if empty The producer for the consumer) to wait if the consumer for the producer) is using the buffer to produce for to consume) include define DUFS 10 define NP3 define NC 2 pthread PNP CINCI: in USE: sem mutex empty in out void produce voidang int p intang: stand timelik dol item= rand) 1001: A random number for producer " Item, in produced item: dat buffer space: bultinj-item: prin "Producerad sleepst: infin-1 BUFSIZE: while (1) return (NULL); void consumer void *arg) { int item; int c = (intjang srand(time(O): dol 516 COEN 177 - Exam 2 Nd comumed item butter space w item, out: bem buffouth print Consumer sleep(10 Out out 1NBURSIZE while (11. return (NULL void cleanuplint sigtype sem unlink("mutex sem unlink(ur) sem_unlink("empty": prinen Terminatingin exitol: int main signal(SIGINT.cleanupl: mutex sem_open("mutex, O_CREAT, 0644, 11: empty sem_open("empty".O_CREAT, 0644, BUFSIZE): full-sem_open("full", O_CREAT, 0644, 0); for (-0p

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!