Monitors in Operating System
Monitors in Operating System
What is Monitor?
It is a synchronization technique that enables threads to mutual exclusion and the wait() for a given condition to become true. It is an
abstract data type. It has a shared variable and a collection of procedures executing on the shared variable. A process may not directly
access the shared data variables, and procedures are required to allow several processes to access the shared data variables
simultaneously.
At any particular time, only one process may be active in a monitor. Other processes that require access to the shared variables must
queue and are only granted access after the previous process releases the shared variables.
Syntax:
monitor {
Advantages
3. Monitors may overcome the timing errors that occur when semaphores are used.
4. Monitors are a collection of procedures and condition variables that are combined in a special type of module.
Disadvantages
https://www.javatpoint.com/semaphore-vs-monitor#:~:text=are as follows%3A-,A semaphore is an integer variable that allows many processes,given condition to become true. 2/3
11/24/22, 5:37 AM Difference between Semaphore and Monitor - javatpoint
3. It gives the compiler the additional burden of knowing what operating system features is available for controlling access to crucial
sections in concurrent processes.
1. A semaphore is an integer variable that allows many processes in a parallel system to manage access to a common resource like a
multitasking OS. On the other hand, a monitor is a synchronization technique that enables threads to mutual exclusion and
the wait() for a given condition to become true.
2. When a process uses shared resources in semaphore, it calls the wait() method and blocks the resources. When it wants to
release the resources, it executes the signal() In contrast, when a process uses shared resources in the monitor, it has to access
them via procedures.
4. In semaphore, an integer variable shows the number of resources available in the system. In contrast, a monitor is an abstract data
type that permits only a process to execute in the crucial section at a time.
5. Semaphores have no concept of condition variables, while monitor has condition variables.
6. A semaphore's value can only be changed using the wait() and signal() In contrast, the monitor has the shared variables and the
tool that enables the processes to access them.
https://www.javatpoint.com/semaphore-vs-monitor#:~:text=are as follows%3A-,A semaphore is an integer variable that allows many processes,given condition to become true. 3/3