| Deadlocks |
| Deadlock Conditions |
| Deadlock Prevention |
| Deadlock Avoidance |
| Banker's Algorithm |
Monitors are a common high-level synchronization tool which solve some of the problems associated with semaphores.
Monitors
are actually a much nicer way of implementing mutual exclusion than semaphores.
One of the reasons for this is that the code that implements mutual exclusion is
all in one place, the monitor. With semaphores that code can distributed all
over the place in the form of wait and signal semaphore function
calls.
Additionally it’s
next to impossible to setup a monitor incorrectly. On the other hand with
semaphores it is quite common to do a wait (B) when you should have done a
wait
(c)
Simple little mistakes are easy to make with semaphores.
Process
synchronization with monitors is implemented in much the same way as it is
implemented with semaphores. However, with monitors you use condition variables
rather than semaphores.
For this reason it is important that you realize the difference between semaphores and condition variables. This is made more difficult because
both
semaphores and condition variables both use wait and signal as the valid
operations,
the
purpose of both is somewhat similar, and
they
are actually quite different.
The main
difference is the operation of signal. With a semaphore the signal operation
actually increments the value of the semaphore. So if there are not any
processes blocked on the semaphore the signal will be "remembered" by the
incrementing of the semaphore.
The signal function on a Monitor’s condition variable is different. If there are no processes blocked on the condition variable then the signal function does nothing. The signal is not remembered. In order to remember "empty signals" you have to use some other form of variable. The good part of this is that using other variables within in monitor is simple because we can be assured that mutual exclusion is being implemented.
Designed By: Harriet B. Nyakaana