From Monitors to Mx/Cv Pairs
Mutexes and condition variables (as in Nachos) are based on the monitors concept, but they are more flexible.
- A monitor is “just like” a module whose state includes a mutex and a condition variable.
The difference is syntactic; the basic semantics (and implementation) are the same for mutex/CV and monitors.
- It’s “just as if” the module’s methods Acquire the mutex on entry and Release the mutex before returning.
- But with mutexes, the critical regions within the methods can be defined at a finer grain, to allow more concurrency.
- With condition variables, the module methods may wait and signal on multiple independent conditions.