Monitors
摘要
All examples shown so far illustrate some disadvantages of the implementation of locks, which cannot be eliminated even with the use of semaphores. We have to thank Hoare for the appropriate answer to this problem: He introduced the package-like concept of monitors. In this chapter, Hoare’s idea is introduced, the necessary terms are clarified, condition variables are introduced as language tool for synchronization, and it is shown how they are applied to the synchronization of various classical problems such as the bounded buffer and the readers-writers problem. The detailed discussion of signal semantics is dedicated to the competition problems of different approaches to the realization of monitors. This is followed by the broadcast concept and monitor solutions for barrier synchronization, the problem of the sleeping barber, Hoare’s alarm clock, and prioritizing the shortest jobs. The final part is a short presentation of the problem of nested monitor calls.