Topic: Monitors: Object-Based Synchronization
Points: 10
Assigned: August 31, 1999
Due: September 7, 1999


In answering the following questions use the readers-writers monitor given in the text.

1. (3 points) This question explores why a monitor enforces mutual exclusion (i.e., no more than one process or thread can be executing in the monitor at any point in time). Suppose that a monitor did not enforce mutual exclusion and consider the readers-writers monitor in the following scenario: a single reader process has just finished reading from the database and has called the endread procedure while a single writer process has just invoked the startwrite procedure. Describe a sequence of actions that results in the writer being unable to access the database even though the reader has relinquished control of the database. Ignore all other reader and writer processes.

2. (3 points) In a given state, the readers-writers monitor has 6 reader processes blocked on the OKtoread condition variable because a writer process was writing to the database. Ignoring all other processes, how many processes will at some point be on the urgent queue from the time when the writer completes until the time when all of the reader processes are reading?

3. (4 points) The database in the readers-writers problem cannot be encapsulated by the monitor. Thus, it is possible for badly programmed processes to directly access the database without the proper synchronization. Show the design of a system in which encapsulation is used to protect the database and guarantee proper synchronization while allowing concurrent reading of the database.