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

Semaphore Class Reference

#include <Semaphore.hpp>

List of all members.

Public Methods

 Semaphore (int init=0, const char *sem_name="", int c=7)
virtual __inline ~Semaphore ()
void P ()
void V ()
SCHAR get ()

Private Methods

__inline Semaphore (const Semaphore &src)
__inline const Semaphore & operator= (const Semaphore &src)

Private Attributes

Mutex m
SCHAR state
char * name
int color
int fg


Constructor & Destructor Documentation

Semaphore::Semaphore int    init = 0,
const char *    sem_name = " ",
int    c = 7
 

Definition at line 11 of file Semaphore.cpp.

00012     : state( init ), color( c ), fg( 0 )
00013   { 
00014     name = (char*)sem_name;
00015     if ( c > 15 ) { color = c - 16; fg++; }
00016     if ( sem_name[0] == 's' ) { fg = 1; }
00017   }

virtual __inline Semaphore::~Semaphore   [inline, virtual]
 

Definition at line 16 of file Semaphore.hpp.

00016 { }

__inline Semaphore::Semaphore const Semaphore &    src [private]
 


Member Function Documentation

void Semaphore::P  
 

Definition at line 19 of file Semaphore.cpp.

00020   {
00021     m.lock();
00022     while ( state < 1 ) 
00023     {
00024       m.unlock();
00025         if ( ++cnt > DEADLOCK_SEM ) { 
00026           printf( "Deadlock(%s=%d|%d)", name, cnt, state ); fflush( stdout );
00027           exit( 1 );
00028         }
00029         sched_yield();
00030       m.lock();
00031     }
00032     --state;  
00033     m.unlock();
00034   }

void Semaphore::V  
 

Definition at line 36 of file Semaphore.cpp.

00036                     {
00037     m.lock();
00038       ++state;
00039     m.unlock();
00040   }     

SCHAR Semaphore::get  
 

Definition at line 42 of file Semaphore.cpp.

00042                        {
00043     register SCHAR s = 0;
00044     m.lock();
00045       s = state;
00046     m.unlock();
00047 
00048     return s;
00049   }     

__inline const Semaphore& Semaphore::operator= const Semaphore &    src [private]
 


Member Data Documentation

int Semaphore::color [private]
 

Definition at line 12 of file Semaphore.hpp.

int Semaphore::fg [private]
 

Definition at line 13 of file Semaphore.hpp.

Mutex Semaphore::m [private]
 

Definition at line 9 of file Semaphore.hpp.

char* Semaphore::name [private]
 

Definition at line 11 of file Semaphore.hpp.

SCHAR Semaphore::state [private]
 

Definition at line 10 of file Semaphore.hpp.


The documentation for this class was generated from the following files:
Generated on Sun Oct 14 18:49:37 2001 for Standard J2K Library by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001