Tuesday 13 March 2012

Monitors


  • High-level synchronization construct that allows the safe sharing of an abstract data type among concurrent processes.
                      monitor monitor-name
                      
                      shared variable declarations
                      procedure body P1 (…) {
                      . . .
                      }
                      procedure body P2 (…) {
                      . . .
                     }
                     procedure body Pn (…) {
                     . . .
                    }  
                    {
                    initialization code
                    }
                    }
  • To allow a process to wait within the monitor, a condition variable must be declared, as


  condition x, y;
  • Condition variable can only be used with the operations wait and signal.

  1. The operation
  x.wait();
means that the process invoking this operation is suspended until another process invokes
  x.signal();
  1. The x.signal operation resumes exactly one suspended process.  If no process is suspended, then the signal operation has no effect.  

No comments:

Post a Comment