The Readers and Writers Problem

The Readers and Writers problem is useful for modeling processes which are competing for a limited shared resource. A practical example of a Readers and Writers problem is an airline reservation system consisting of a huge data base with many processes that read and write the data. Reading information from the data base will not cause a problem since no data is changed. The problem lies in writing information to the data base. If no constraints are put on access to the data base, data may change at any moment. By the time a reading process displays the result of a request for information to the user, the actual data in the data base may have changed. What if, for instance, a process reads the number of available seats on a flight, finds a value of one, and reports it to the customer. Before the customer has a chance to make their reservation, another process makes a reservation for another customer, changing the number of available seats to zero.

In the following pages, we will look at solutions to this problem using semaphores, monitors, and message passing.

In the next three sections, the Orange Line, we will discuss solutions to this problem using each of the three methods mentioned in the Solution Types section:

Semaphores
Monitors
Message Passing

             
IPC Home    Subway    Problems    Producer/
  Page       Map                  Consumer