fdhwlib  2.0.25
semaphore Class Reference

#include <semaphore.h>

List of all members.

Public Member Functions

Private Member Functions

Private Attributes


Detailed Description

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.

Todo:

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.

Todo:
Add optional argument to the constructor to define a message stream.

Definition at line 92 of file semaphore.h.


Constructor & Destructor Documentation

semaphore::semaphore ( int  mid = 0,
const char *  dir = "/" 
)

Creates a Semaphore array.

Parameters:
midNumber of the (first) Semaphore in the array
dirName of the base directory

Member Function Documentation

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)

Member Data Documentation

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.


The documentation for this class was generated from the following file: