Semaphore manager.
More...
The semaphore manager is responsible for managing the semaphores used during the concurrent sections of the program. Each semaphore must first be registered using addSemaphore. The state of semaphores are adjusted via the waitSemaphore and signalSemaphore methods.
void SemaphoreManager::addSemaphore |
( |
const char * |
name, |
|
|
sem_t * |
sem, |
|
|
int |
value |
|
) |
| |
Registers a new semaphore.
- Parameters
-
[in] | name | name of semaphore |
[in] | sem | semaphore variable |
[in] | value | initial value of semaphore |
void SemaphoreManager::waitSemaphore |
( |
int |
id, |
|
|
sem_t * |
sem |
|
) |
| |
Decrement the semaphore. If the value is negative, the thread must wait until woken up by a subsequent post operation.
- Parameters
-
[in] | id | id of thread performing wait |
[in] | sem | semaphore variable |
void SemaphoreManager::signalSemaphore |
( |
int |
id, |
|
|
sem_t * |
sem |
|
) |
| |
Increment the semaphore. If one or more threads are waiting, one thread will be woken up.
- Parameters
-
[in] | id | id of thread performing signal (post) |
[in] | sem | semaphore variable |
string SemaphoreManager::getSemaphoreTable |
( |
) | |
const |
Returns the semaphore table in a string in a trace-friendly format.