fdhwlib
2.0.25
|
#include <semaphore.h>
The class semaControl is intended to maintain the state of the semaphore arrays.
Every instance contains the key information of the array. (Calculated form a directory name and the project character 's' for semaphore, see SysV key!). The instance not necessarily contains a valid semaphore identifier (sid) - before any other command use open() or create().
To supervise the semaphores form system level use the OS commands ipcs, ipcrm.
Definition at line 158 of file semaphore.h.
semaControl::semaControl | ( | ) |
semaControl::semaControl | ( | const char * | dir | ) |
Creates a Semaphore array.
dir | Name of the base directory |
void semaControl::create | ( | int | members | ) |
Create a new array of semaphores.
key_t semaControl::getKey | ( | ) |
Returns the key of the semphore array This is the number that can be found in the display of the system command "ipcs".
void semaControl::init | ( | const char * | dir | ) | [private] |
void semaControl::lock | ( | int | nr | ) |
Lock a semphore.
WARNING: The method will modify a semaphore independantly of the access rights
void semaControl::markForDelete | ( | ) |
Mark the semaphore for delete.
Do not use this command on a semaphore array another process may depend on.
int semaControl::number | ( | ) |
Returns the number of semaphores in the array.
void semaControl::open | ( | ) |
Open semaphore pointer to an existing semaphore.
void semaControl::unlock | ( | int | nr | ) |
Unlock a semphore.
WARNING: The method will modify a semaphore independantly of the access rights
int semaControl::value | ( | int | nr | ) |
Returns the value of a semaphore.
Have always in mind, that in a running system it is useless to read the value of a semaphore. The information is only valid for the time the value is read. You can base any decicions on tis value! Use request() instead.
key_t semaControl::key [private] |
Definition at line 221 of file semaphore.h.
int semaControl::max [private] |
Definition at line 219 of file semaphore.h.
int semaControl::memid [private] |
Definition at line 218 of file semaphore.h.
int semaControl::sid [private] |
Definition at line 217 of file semaphore.h.