Q5Operating System
Question
What is Monitor?
Answer
A monitor is a high-level synchronization construct that encapsulates shared data and the procedures to access it, ensuring mutual exclusion automatically.
A monitor is an abstract data type (ADT) that encapsulates shared data variables and the procedures (operations) that operate on them, along with a synchronization mechanism. The monitor guarantees that only one process can be active within the monitor at a time (mutual exclusion is automatic). Condition variables (cond.wait() and cond.signal()) are used within monitors to allow processes to wait for specific conditions. Monitors are easier and safer to use than semaphores for writing correct concurrent programs. Example: Java's synchronized keyword provides monitor-like behavior.