Monitors examples process synchronization role procedures shared data Operating Systems (OS)
By: Prof. Dr. Fazal Rehman | Last updated: March 3, 2022
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 areprocedures(operations)?A monitor is an abstract data type that is used for synchronizing the processes.A monitor contains theshared data variables and procedures(operations).What are Shared data variables?Shared data variables are shared by all the processes.What areprocedures(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.Figure: Monitors process synchronization operating systems OS.Example of monitor
C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
MonitorBankAccount
{
doublebalance;
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.