Monitors in Operating System

An abstract data type—or ADT—encapsulates data with a set of functions to operate on that data that are independent of any specific implementation of the ADT. A monitor type is an ADT that includes a set of programmer defined operations that are provided with mutual exclusion within the monitor. The monitor type also declares the variables whose values define the state of an instance of that type, along with the bodies of functions that operate on those variables. Thus, a function defined within a monitor can access only those variables declared locally within the monitor and its formal parameters. Similarly, the local variables of a monitor can be accessed by only the local functions

Syntax of a monitor

monitor monitor name
{
/* shared variable declarations */
function P1(...) {
...
}
function P2(...) {
...
}
.
.
.
function Pn(...) {
...
}
initialization code (...) {
...
}
}

Leave a Comment