Condition Variable

A condition variable is a type representing a queue of suspended (delayed) processes or threads waiting on some condition. It can be considered as part of the monitor synchronization mechanism, and it used by a process or thread to delay until the monitor's state satisfies some condition; it is also used to awaken a delayed process when the condition becomes true. Two basic operations are defined:
  • wait: enqueue the calling process on the condition variable.
  • signal: wake up one process waiting on the condition variable (if there is one). (Different implementations of signal are possible; it may be guaranteed to awaken the process at the head of the queue, or it may be simply guaranteed to awaken some process from the queue.)
Example: A monitor for the producer-consumer problem.
  monitor ProducerConsumer  {      ItemType bufferslots;      Condition bufferHasSpace, bufferHasData;        procedure putItem(ItemType & item)      {          while(itemCount == slots)              bufferHasSpace.wait();          buffer.add(item);          bufferHasData.signal();      }        procedure getItem(ItemType & item)      {          while(itemCount == 0)              bufferHasData.wait();          item = buffer.removeFirst();          bufferHasSpace.signal();      } 
}

 

<< PreviousWord BrowserNext >>
longtime companion
david chase
east and west memorial buildings
general grievous shakar
mr. saturday night
androgynous pronoun
kahikatea
ghosts of mississippi
xcp
a civil action
baby corn
tagus bridge
outworld
chuck (sonic the hedgehog)
elemental analysis
hellen ingram plummer
ghanananda
till plain
s4
swatbot
vishuddhananda
band sum
lucius quintus cincinnatus lamar (i)
bojonegoro
bit pattern
eunos
ym
list of titled doctor who episodes
shankarananda
sheila finestone
un (disambiguation)
oral rehydration salts
monitor (computer science)
lucius quintus cincinnatus lamar
cocoa tea
daoji
january 2005 in the united states
millicent library
martha salazar
common technical document
eating black milk
ccgs cape roger
victoria palace
ctd