fdhwlib
2.0.25
|
#include <semaphore.h>
The class provides semaphores.
With Linux the SysV style semaphores are used.
The function of the semaphores is crucial to all applications relying on Pbus-access. To maintain the state of the semaphores use the program "semtool" or the system commands "ipcs" and "ipcrm".
List the state of the semphores.
semtool t
After an abnormal program end it can happen, that semapohres stay locked. Any access to the electronic will be impossible in this state. Use "semtool" to clear the state of the semaphores.
Would be nice to have named semaphores with a automatic numbering?!
There is another definition of semaphores in semaphore.h. Is this useful?
GUI programm for Windows NT also need protection, when multiple threads are used! Try to adapt a version with the MFC Semaphores.
Definition at line 92 of file semaphore.h.
semaphore::semaphore | ( | int | mid = 0 , |
const char * | dir = "/" |
||
) |
Creates a Semaphore array.
mid | Number of the (first) Semaphore in the array |
dir | Name of the base directory |
key_t semaphore::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 semaphore::init | ( | int | mid, |
const char * | dir | ||
) | [private] |
int semaphore::number | ( | ) |
Returns the number of semaphores in the array.
void semaphore::release | ( | int | nr = 0 | ) |
void semaphore::request | ( | int | nr = 0 | ) |
key_t semaphore::key [private] |
Definition at line 125 of file semaphore.h.
CSingleLock* semaphore::lock0 [private] |
Definition at line 137 of file semaphore.h.
CSingleLock* semaphore::lock1 [private] |
Definition at line 138 of file semaphore.h.
int semaphore::max [private] |
Definition at line 128 of file semaphore.h.
int semaphore::memid [private] |
Definition at line 122 of file semaphore.h.
CMutex* semaphore::mutex0 [private] |
Definition at line 134 of file semaphore.h.
CMutex* semaphore::mutex1 [private] |
Definition at line 135 of file semaphore.h.
int semaphore::sid [private] |
Definition at line 127 of file semaphore.h.