Question: Explain what is the problem with this implementation of the one-writer many-readers problem? // shared and initialized to 0 // shared and initialized to 1;
Explain what is the problem with this implementation of the one-writer many-readers problem?
// shared and initialized to 0 // shared and initialized to 1; int readcount; Semaphore mutex, wrt; // Writer : // Readers : semWait (mutex); readcount := readcount + 1; semWait (wrt); if readcount == 1 then semWait (wrt); semSignal (mutex); /*reading performed*/ semWait (mutex); /* Writing performed*/ semsignal (wrt); readcount := readcount 1; if readcount semSignal (mutex); o then Up (wrt) ;
Step by Step Solution
3.42 Rating (158 Votes )
There are 3 Steps involved in it
Readers not being able to read simultaneously does not mean starvation although simultaneous re... View full answer
Get step-by-step solutions from verified subject matter experts
