Monitors
Monitors
By
P.Vinitha
Monitors
• Monitor is a software module
• Chief characteristics
Local data variables are accessible only by the
monitor
Process enters monitor by invoking one of its
procedures
Only one process may be executing in the
monitor at a time
Monitors
• High-level synchronization construct that allows the safe sharing of
an abstract data type among concurrent processes.
type monitor-name = monitor
variable declarations
procedure entry P1 :(…);
begin … end;
procedure entry P2(…);
begin … end;
procedure entry Pn (…);
begin…end;
begin
initialization code
end
Monitors (Cont.)
• To allow a process to wait within the monitor, a condition
variable must be declared, as
var x, y: condition
• Condition variable can only be used with the operations wait
and signal.
The operation
x.wait;
means that the process invoking this operation is suspended until
another process invokes
x.signal;
The x.signal operation resumes exactly one suspended process. If no
process is suspended, then the signal operation has no effect.
Schematic view of a monitor
Monitor with condition variables