#include <synch.h>
Public Methods | |
| Condition (char *debugName) | |
| initialize condition to "no one waiting". More... | |
| ~Condition () | |
| deallocate the condition. More... | |
| char* | getName () |
| void | Wait (Lock *conditionLock) |
| void | Signal (Lock *conditionLock) |
| void | Broadcast (Lock *conditionLock) |
Private Attributes | |
| char* | name |
| List<Semaphore *>* | waitQueue |
| list of waiting threads. More... | |
Definition at line 124 of file synch.h.
|
|
initialize condition to "no one waiting". Condition::Condition Initialize a condition variable, so that it can be used for synchronization. Initially, no one is waiting on the condition. "debugName" is an arbitrary name, useful for debugging. |
|
|
deallocate the condition. Condition::Condition Deallocate the data structures implementing a condition variable. |
|
|
Condition::Broadcast Wake up all threads waiting on this condition, if any. "conditionLock" -- lock protecting the use of this condition |
|
|
Condition::Signal Wake up a thread waiting on this condition, if any. Note: we assume Mesa-style semantics, which means that the signaller doesn't give up control immediately to the thread being woken up (unlike Hoare-style). Also note: we assume the caller holds the monitor lock (unlike what is described in Birrell's paper). This allows us to access waitQueue without disabling interrupts. "conditionLock" -- lock protecting the use of this condition Definition at line 273 of file synch.cc. Referenced by SynchList::Append(), and Broadcast().
|
|
|
Condition::Wait Atomically release monitor lock and go to sleep. Our implementation uses semaphores to implement this, by allocating a semaphore for each waiting thread. The signaller will V() this semaphore, so there is no chance the waiter will miss the signal, even though the lock is released before calling P(). Note: we assume Mesa-style semantics, which means that the waiter must re-acquire the monitor lock when waking up. "conditionLock" -- lock protecting the use of this condition Definition at line 244 of file synch.cc. Referenced by SynchList::RemoveFront().
|
|
|
|
|
|
|
|
|
list of waiting threads.
|
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001