Question: Below is an algorithm for Readers - Writers problem. Fill in the table of the values of semaphores or variables. Shared data semaphore mutex, db;

Below is an algorithm for Readers-Writers problem. Fill in the table of the values of semaphores or variables.
Shared data
semaphore mutex, db;
Initially
mutex =1, db =1, readcount =0
Writer process:
wait(db);
...
writing is performed
...
signal(db);
Reader process:
wait(mutex);
readcount++;
if (readcount ==1)
wait(db);
signal(mutex);
...
reading is performed
...
wait(mutex);
readcount--;
if (readcount ==0)
signal(db);
signal(mutex):
event mutex db readcount
a writer comes
a reader comes
a writer has done
a reader comes
a reader comes
a writer comes
a reader has done
a reader has done
a reader has done
a writer comes

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!