Question: Q3. Reader-Writer [10 points]: There is 1 thread that writes to a file, and a number of other threads that can simultaneously read the file,

Q3. Reader-Writer [10 points]: There is 1 thread that writes to a file, and a number of other threads that can simultaneously read the file, but never the readers and the write together (e.g., at one time, 3 reader threads are running, at another time the writer thread is running). Write pseudo code using semaphores for both the Reader() and Writer() functions. Remember that there is no data dependency between the readers and the writer (i.e., it is not a producer-consumer problem), the only condition is that they do not happen at the same time. Hint: The first reader to get access waits until the ongoing writer (if any) finishes, performs the read operation and leaves. The last reader, just before leaving, should give control/access back to the writer (if any) waiting. Think about the initial values of the semaphores.

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!