MONITORS
MONITORS
monitor monitor_name
{
//Shared variable declarations
Procedure body P1 (………) {
........
}
Procedure body P2 (………) {
........
}
.
.
Procedure body Pn (………) {
........
}
{
Initialization Code
}
}
1
Condition Variables:
Condition variables are synchronization primitives that enable threads to wait until a
particular condition occurs.
Two different operations are performed on the condition variables of the monitor:
1) Wait.
2) Signal.
Let us say we have 2 condition variables condition x, y; //Declaring variable
Wait operation:
x.wait (): Process performing wait operation on any condition variable is
suspended. The suspended processes are placed in block queue of that condition
variable.
Signal operation:
x.signal (): When a process performs signal operation on condition variable, one of the
blocked processes is given chance.
Schematic View of a Monitor: