CS 3733 Operating Systems Notes: Monitors


Get Dining Philosophers Monitor Pseudocode (book)
Get Dining Philosophers Monitor Pseudocode (Mine)
Get Bounded Buffer in Java


Monitors were developed in the 1970s to make it easier to avoid deadlocks.


An example: Dining Philosophers

Dining Philosophers

Look at code for almost solving this using monitor pseudocode.

Note that this "solution" allows starvation.


Monitor Implementation
Monitors are implemented by using queues to keep track of the processes attempting to become active int he monitor.

To be active, a monitor must obtain a lock to allow it to execute the monitor code.
Processes that are blocked are put in a queue of processes waiting for an unblocking event to occur.
These are the queues that might be used:

The relative priorities of these queues determines the operation of the monitor implementation.

The queues associated with a monitor that does not have a signaller queue. The lock becomes available when the active process executes a wait or leaves the monitor.

Additional information about monitors can be found in: Starving Philosophers: Experimentation with Monitor Synchronization.

This describes a monitor simulator for the Dining Philosophers Problem.


One modern language that uses monitors is Java.