Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

PsnSemaphore Class Reference

PsnSemaphore : abstract semaphores for openMask. More...

#include <PsnSemaphore.h>

Inheritance diagram for PsnSemaphore:

Inheritance graph
[legend]
List of all members.

Public Methods

 PsnSemaphore (const int valeurInitiale)
 Constructor.

virtual ~PsnSemaphore ()
 Destructor.

virtual int V ()=0
 V Increments the semphore value and signals the change to blocked threads.

virtual int P ()=0
 P decrement the sempaphore value and block the calling thread if this value is negative.


Detailed Description

PsnSemaphore : abstract semaphores for openMask.

Author:
D. Margery
Version:
1.1

Definition at line 26 of file PsnSemaphore.h.


Constructor & Destructor Documentation

PsnSemaphore::PsnSemaphore const int    valeurInitiale [inline]
 

Constructor.

Parameters:
int initial value of the semaphore

Definition at line 33 of file PsnSemaphore.h.

00033 {};

PsnSemaphore::~PsnSemaphore   [inline, virtual]
 

Destructor.

Definition at line 38 of file PsnSemaphore.h.

00038 {};


Member Function Documentation

int PsnSemaphore::P   [pure virtual]
 

P decrement the sempaphore value and block the calling thread if this value is negative.

Returns:
: old value of the semaphore

Implemented in PsnPthreadSemaphore, PsnSequentialSemaphore, and PsnSprocSemaphore.

Definition at line 98 of file PsnSemaphore.cxx.

00098                     {
00099   int retval,ret;
00100   ret=pthread_mutex_lock(&mutex);
00101   if(ret) {
00102     perror("PsnSemaphore : P a echoue au niveau du mutex lock");
00103   }
00104   v--;
00105   while(v<0) {
00106     ret=pthread_cond_wait(&cond,&mutex);
00107     if(ret) {
00108       perror("PsnSemaphore : P a echoue au niveau du cond");
00109     }
00110   }
00111   retval=v;
00112   ret=pthread_mutex_unlock(&mutex);
00113   if(ret) {
00114     perror("PsnSemaphore : P a echoue au niveau du mutex unlock");
00115   }
00116   return (retval);
00117 }

int PsnSemaphore::V   [pure virtual]
 

V Increments the semphore value and signals the change to blocked threads.

Returns:
: new value of the semaphore

Implemented in PsnPthreadSemaphore, PsnSequentialSemaphore, and PsnSprocSemaphore.

Definition at line 79 of file PsnSemaphore.cxx.

00079                     {
00080   int retval,ret;
00081   ret=pthread_mutex_lock(&mutex);
00082   if(ret) {
00083     perror("PsnSemaphore : V a echoue au niveau du mutex lock");
00084   }
00085   v++;
00086   retval=v;
00087   ret=pthread_mutex_unlock(&mutex);
00088   if(ret) {
00089     perror("PsnSemaphore : V a echoue au niveau du mutex unlock");
00090   }
00091   ret=pthread_cond_signal(&cond);
00092   if(ret) {
00093     perror("PsnSemaphore : V a echoue au niveau du cond");
00094   }
00095   return(retval);
00096 }


The documentation for this class was generated from the following files:
logo OpenMask

Documentation generated on Mon Nov 25 15:26:25 2002

Generated with doxygen 1.2.12 by Dimitri van Heesch ,   1997-2001