#include <synch.h>
Public Methods | |
| Lock (char *debugName) | |
| initialize lock to be FREE. More... | |
| ~Lock () | |
| deallocate lock. More... | |
| char* | getName () |
| debugging assist. More... | |
| void | Acquire () |
| these are the only operations on a lock. More... | |
| void | Release () |
| they are both *atomic*. More... | |
| bool | IsHeldByCurrentThread () |
| return true if the current thread holds this lock. More... | |
Private Attributes | |
| char* | name |
| debugging assist. More... | |
| Thread* | lockHolder |
| thread currently holding lock. More... | |
| Semaphore* | semaphore |
| we use a semaphore to implement lock. More... | |
Definition at line 69 of file synch.h.
|
|
initialize lock to be FREE. Lock::Lock Initialize a lock, so that it can be used for synchronization. Initially, unlocked. "debugName" is an arbitrary name, useful for debugging. |
|
|
deallocate lock. Lock::~Lock Deallocate a lock |
|
|
these are the only operations on a lock. Lock::Acquire Atomically wait until the lock is free, then set it to busy. Equivalent to Semaphore::P(), with the semaphore value of 0 equal to busy, and semaphore value of 1 equal to free. Definition at line 181 of file synch.cc. Referenced by SynchList::Append(), SynchConsoleInput::GetChar(), SynchConsoleOutput::PutChar(), SynchDisk::ReadSector(), SynchList::RemoveFront(), PostOfficeOutput::Send(), Condition::Wait(), and SynchDisk::WriteSector().
|
|
|
return true if the current thread holds this lock.
Definition at line 78 of file synch.h. Referenced by Release(), Condition::Signal(), and Condition::Wait().
|
|
|
they are both *atomic*. Lock::Release Atomically set lock to be free, waking up a thread waiting for the lock, if any. Equivalent to Semaphore::V(), with the semaphore value of 0 equal to busy, and semaphore value of 1 equal to free. By convention, only the thread that acquired the lock may release it. Definition at line 198 of file synch.cc. Referenced by SynchList::Append(), SynchConsoleInput::GetChar(), SynchConsoleOutput::PutChar(), SynchDisk::ReadSector(), SynchList::RemoveFront(), PostOfficeOutput::Send(), Condition::Wait(), and SynchDisk::WriteSector().
|
|
|
debugging assist.
|
|
|
thread currently holding lock.
|
|
|
debugging assist.
|
|
|
we use a semaphore to implement lock.
|
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001