Monitors in Operating System

By | October 11, 2021

Monitors in Operating System (OS)

  • A monitor is a programming language in OS that construct that guarantees an appropriate access to critical section. Thus, a monitor is a software synchronization tool.
  • It is a facility provided by language system, and it is not a service provide by operating system.
  • Many programming languages like concurrent Pascal, Modula-2, Modula-3 and Java provide monitors.
  • A monitor is a software module consisting of one or more procedures, local data and an initialization sequence.

The major characteristics of a monitor are the following : 

  1. The local data variables of monitor are accessible only by the monitor’s procedures and not by any external procedure.
  2. Processes cannot directly access the monitor’s internal data but they can call procedures in a monitor. Thus, a process enters the monitor by invoking one of its procedures.
  3. Only one process can be active at a time in monitor i.e. only one process may E executing in the monitor at a time.
  4. When a process calls a monitor procedure and any other process is active in monitor then the calling process is suspended. Such a suspended process waits until the monitor becomes available. In this way a monitor fulfills mutual. exclusion requirement.
Syntax of a monitor
  • Each monitor has an entry queue, and processes that want to call a monitor routine join this queue if the monitor is already in use.
Monitor     monitor-name
      shared variable declarations
      procedure body P1 (........)
      procedure body P2 (........)
           procedure body Pn (........)
      initialization code
  • As we know, that mutual exclusion not sufficient for concurrent programming, an additional mechanism also required to block the processes when one process active in monitors. Such a mechanism is provided by using condition constructs.
Schematic View of Monitor

Such condition constructs works as follows in Monitors in Operating System:

1. A programmer can define one or more variables of type condition.

Condition m, n;

2.Two different operations can defined on these condition variables. These are: wait and signal.

3. The operation m.wait ( ) signifies that the process which invokes this operation suspended until another process invokes m.signal ( ).

4. The m.signal ( ) operation starts exactly one suspended process.

5. The state of m remains unchanged, if there is no suspended process. In other words, signal lost when there  no suspended process.

6. Suppose when m.signal ( ) invoked by process. A then there exists a suspended process B associated with that condition. If B resumes execution, A must wait. Otherwise two processes will be active at one time in monitor. There are two possibilities in this condition :

(a) Either B can wait for monitor to be empty or wait for another condition.

(b) Either A can wait for monitor to be empty or wait for another condition.

7. If a number of processes are suspended on m condition and some process executes m.signal ( ) operation then which process to resume next can be determined by FCFS basis.

Monitors in Operating System

Disadvantage of Monitors in Operating System (OS)

The major disadvantage of monitor concept, its lack of implementation in most commonly used programming languages. While semaphore are not included in most languages either, P and V operations are easily added as independent subroutines or as operating system supervisor calls. Monitors cannot easily added if they not natively supported by the language.

2 thoughts on “Monitors in Operating System

  1. Reina

    My spouse and I stumbled over here different website and thought I may as well check things out.

    I like what I see so i am just following you. Look forward to
    finding out about your web page for a second time.

  2. Hannelore

    Nice post. I was checking constantly this blog and I’m impressed!
    Very useful information specifically the last part 🙂 I care for such
    info much. I was looking for this certain information for a very long time.
    Thank you and best of luck.


Leave a Reply

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