Figure 1: Pseudocode for put routine

void put(Data *p) {
   // lock the monitor
   Wait on MonitorMutex

   // test the Predicate 
   // which can be any arbitrary logical expression
   While (there is no space in the deque) {
      --- OPERATING SYSTEM ATOMIC ---
      SignalObjectAndWait(...); 
      
      // unlock the monitor
      Signal MonitorMutex

      // wait for a pulse from the get method
      Wait on event SpaceAvailable
      --- END OPERATING SYSTEM ATOMIC ---
   
      // relock the monitor
      Wait on MonitorMutex
   }

   // at this point it is guaranteed that
   // MonitorMutex is locked and there is space in the deque
   Push the data onto the deque

   // signal next getter that an element is there
   Pulse event ElementAvailable

   // unlock the monitor
   Signal MonitorMutex
}