Question: Recall the Readers/Writers problem: readers processes query a database and writer processes examine and modify it. Readers may access the database concurrently, but writers require

 Recall the Readers/Writers problem: readers processes query a database and writer

Recall the Readers/Writers problem: readers processes query a database and writer processes examine and modify it. Readers may access the database concurrently, but writers require exclusive access. Although the database is shared, we cannot encapsulate it by a monitor, because readers could not then access it concurrently since all code within a monitor executes with mutual exclusion. Instead, we use a monitor merely to arbitrate access to the database. The database itself is global to the readers and writers. In the Readers/Writers problem, the arbitration monitor grants permission to access the database. To do so, it requires that processes inform it when they want access and when they have finished. There are two kinds of processes and two actions per process, so the monitor has four procedures: request_read, release_read, request_write, release_write. These procedures are used in the obvious ways. For example, a reader calls request_read before reading the database and calls release_read after reading the database. To synchronize access to the database, we need to record how many processes are reading and how many processes are writing. In the implementation below, nr is the number of readers, and nw is the number of writers; both of them are initially 0 . Each variable is incremented in the appropriate request procedure and decremented in the appropriate release procedure. A beginner software developer has implemented this code, but has unfortunately missed a lot of details related to synchronization. Help the beginner developer fix this code

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!