Monitors examples process synchronization role procedures shared data Operating Systems (OS)
Monitors examples in process synchronization in Operating Systems (OS)
In this tutorial, we will try to learn the followings;
- What is a monitor in operating systems?
- What are Shared data variables?
- Example of monitor
- What is the role of the monitor in-process synchronization?
What are procedures(operations)?
A monitor is an abstract data type that is used for synchronizing the processes.
A monitor contains the shared data variables and procedures(operations).
What are Shared data variables?
Shared data variables are shared by all the processes.
What are procedures(operations)?
Procedures(operations) allow processes to execute in mutual exclusion within the monitor. A process can only get the access to shared data variables in the monitor if procedures in the monitors allow the process. Monitors take care of all synchronization among processes.
Is it possible that a process directly accesses the shared data variable in the monitor?
No, it is not possible. A process can not directly access the shared data variable in the monitor. Accessing of shared data is controlled by procedures in the monitor.
Example of monitor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
Monitor BankAccount { double
balance; WithdrawMoney(TotalAmount) { balance = balance – TotalAmount; display balance; }} |
What is the role of the monitor?
Procedures in the monitors help the operating systems to synchronize the processes.