Question: Assume the writepending semaphore was omitted from Figure. Describe a simple sequence of reader and writer activity that causes the solution to fail for the

Assume the writepending semaphore was omitted from Figure. Describe a simple sequence of reader and writer activity that causes the solution to fail for the second readers-writerspolicy.

writer () { reader () { while (TRUE) { while (TRUE) {

writer () { reader () { while (TRUE) { while (TRUE) { ; P(mutex2); writecount=writeCount+l; if (writeCount==1) P(readBlock); V (mutex2); P(writeBlock); access (resource); V (writeBlock); P(mutex2); writeCount=writeCount-1; ; P(writePending); P(readBlock); P(mutex1); readCount = readCount+1; if(readCount == 1) P(writeBlock); V (mutexl); V(readBlock); V (writePending); access (resource); if (writeCount=30) V(readBlock); P(mutex1); readCount = readCount-1; if(readCount == 0) V(writeBlock); V (mutex1); V ( mutex2); resourceType *resource; int readCount semaphore mutex1 semaphore readBlock = 1; semaphore writePending = 1; semaphore writeBlock = 0, writeCount = 0; 1, mutex2 = 1; /* Start the readers and writers */ fork(reader, 0); /* Could be many */ fork (writer, 0); /* Could be many */

Step by Step Solution

3.44 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is a solution Time Action Result 0 Reader 1 arrives 1 Reader 1 exec... 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 (453).docx

120 KBs Word File

Students Have Also Explored These Related Computer Engineering Questions!