Question: In the solution to the bounded buffer problem (Figure), consider the ordering of the first two P operations in the producer and the consumer. Suppose

In the solution to the bounded buffer problem (Figure), consider the ordering of the first two P operations in the producer and the consumer. Suppose the order of the p(full) and the p(mutex) instructions were reversed in the consumer. Would this solution still becorrect?

producer () { bufType *next, *here; while (TRUE){ produceItem ( next); /*Claim

producer () { bufType *next, *here; while (TRUE){ produceItem ( next); /*Claim an empty buffer / P(empty); /* Manipulate the pool / P(mutex); here - obtain(empty); consumer (){ bufType *next, *here;: while (TRUE) ( /* Claim a full buffer / P(full); /* Manipulate the pool */ P(mutex); here - obtain (full); V (mutex); copyBuffer(here, next); /* Manipulate the pool */ V(mutex); copyBuffer (next, here) : /* Manipulate the pool */ P(mutex); release(here, fullPool); V (mutex); /* signal a full buffer */ V( full); P(mutex); release(here, emptyPool); V (mutex); /* Signal an empty buffer */ V(empty); consumeItem( next); semaphore mutex - 1; semaphore full - 0; semaphore empty - N; bufType buffer[N]; fork (producer, 0); fork(consumer, 0):

Step by Step Solution

3.26 Rating (178 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Then if all the buffers were to become empty at one time the consumer would obtain ... View full answer

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

Document Format (1 attachment)

Word file Icon

34-E-CE-OS (452).docx

120 KBs Word File

Students Have Also Explored These Related Computer Engineering Questions!