Describe the difference between a monitor and a semaphoreSol
Describe the difference between a monitor and a semaphore
Solution
Monitor: Monitor is a highly structured programming language construct.It consists of Private variables and private procedures that can only be used within a monitor. Constructors that initialize the monitor.A number of public monitor procedures that can be invoked by users.
These monitors have no public data.A monitor is a mini OS with monitor procedures as system calls.
Semaphore: Semaphore is a data structure that is used to provide mutual exclusion to critical sections. Semaphores mainly support two operations called wait and Signal . The wait operation blocks a process until the semaphore is open and the signal operation allows another process to enter.
| Monitor | Semaphore |
| Condition variables only uses these Monitors | These can be used in anywhere but not in Monitors |
| wait() always blocks it\'s caller | wait() does not always blocks it\'s caller |
| signal() either releases a process or the signal is lost as if it never occurs | signal() either releases a process or increases Semaphore counter |
| if signal() releases a process,either the caller or the released continues,but not both | if signal() releases a process,the caller and the released both continued |
