What is Monitor?

Monitor :

To overcome the timing errors that occurs while using semaphore for process synchronization, the researchers have introduced a high-level synchronization construct i.e. the monitor type. It is an abstract data type that is used for process synchronization.

Being an abstract data type, It contains the shared data variables that are to be shared by all the processes and some programmer-defined operations that allow processes to execute in mutual exclusion within the monitor. A process can not directly access the shared data variable in the monitor; the process has to access it through procedures defined in the it which allow only one process to access the shared variables in a monitor at a time.

The syntax  is as follow:

It is a construct such as only one process is active at a time within the monitor. If other process tries to access the shared variable in it, it gets blocked and is lined up in the queue to get the access to shared data when previously accessing process releases it.

Conditional variables were introduced for additional synchronization mechanism. The conditional variable allows a process to wait inside the monitor and allows a waiting process to resume immediately when the other process releases the resources.

The conditional variable can invoke only two operation wait() and signal(). Where if a process P invokes a wait() operation it gets suspended in it till other process Q invoke signal() operation i.e. a signal() operation invoked by a process resumes the suspended process.

Leave a Reply

Your email address will not be published. Required fields are marked *