The problem associated with semaphores is
- wait(s) and signal(s) are scattered among several processes Therefore, it is difficult to understand their effects.
- Usage must be correct in all processes.
- One bad process (or one programming error) can kill the whole system.
Monitors are a synchronization construct that was created to overcome the problems caused by semaphores such as timing errors.
Monitors are abstract data types and content shared data variables and procedures. The shared data variables cannot be directly accessed by a process and procedures are required to allow a single process to access the shared data variables at a time.
- Mutual exclusion is automatic in monitors.
- Monitors are less difficult to implement than semaphores.
- Monitors may overcome the timing errors that occur when semaphores are used.
- Monitors are a collection of procedures and condition variables that are combined in a special type of module.
- Monitors must be implemented into the programming language.
- The compiler should generate code for them.
- It gives the compiler the additional burden of knowing what operating system features are available for controlling access to crucial sections in concurrent processes.