MonitorImplementation

MonitorImplementation - Summary on Monitor Implementation...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Summary on Monitor Implementation techniques References Wikipedia on Monitor Concept Textbook Java Multithreading and Synchronization Mechanism Summary on OS course web site Note: in this document we use process and thread interchangeably. Monitor is neither a process (thread) nor an active entity. It is just an abstract data type (or class) whose code can be executed by only one process (or thread) at a time. A monitor object is an object intended to be used to coordinate multiple threads. Methods in the monitor can be either invoked static or non-static ways (creates monitor objects). The methods defined in the monitor are executed with mutual exclusion. That is, at each point in time, at most one thread may be executing any of its methods. Monitors also provide a mechanism for threads to temporarily give up exclusive access, in order to wait for some condition to be met, before regaining exclusive access and resuming their task. Monitors also have a mechanism for signaling other threads that such conditions have been met. Need of Condition Variables in the Monitor For many applications, mutual exclusion is not enough. Threads attempting an operation may need to wait until some condition P holds true. A busy waiting (or spin lock) is not an efficient solution for implementing wait() operation associated with a condition variable. Because by the definition of the monitor, only one thread is allowed in the monitor, the thread with busy waiting will prevent any other thread from entering the monitor to make the condition true. A condition variable defined in the monitor is associated with a queue on which a thread may wait for some condition to become true. Thus each condition variable c is associated with an assertion P c . While a thread is waiting on a condition variable, that thread is not considered to occupy the monitor, and so other threads may enter the monitor to change the monitor's state. In most types of monitors, these other threads may signal the condition variable c to indicate that assertion P c is true in the current state. Thus there are two main operations required on condition variables:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2012 for the course CMP 426 taught by Professor Gwangs.jung during the Spring '12 term at CUNY Lehman.

Page1 / 6

MonitorImplementation - Summary on Monitor Implementation...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online