CIS 307: Implementing Hoare's Monitors

Monitors are treated very nicely in Tanenbaum section 2.2.7 and section 2.2.9. Here I show the implementation of monitors using semaphores in the case that the Signal command can be applied anytime within the monitor, not just, as in Tanenbaum, when exiting monitor calls. That is, while Tanenbaum shows the Brinch Hansen implementation for monitors, here we examine the Hoare implementation. This latter implementation is less restrictive and less efficient. It is interesting as an example of complex concurrent program and it is useful if you want to use monitors in your programs. In fact, though monitors were intended for use as language constructs when programming in languages such as Concurrent Pascal, or Concurrent Euclid, monitors, as an idea, can be used very conveniently in our concurrent programs written in C and using Unix system services.

Most of the code we present appears in Silberschatz et al: Operating Systems Concepts.

We want to show how to implement a monitor using semaphores.

Notes

ingargiola.cis.temple.edu