/**CFile***********************************************************************

  FileName    [my_semaphore.h]

  Synopsis    [Functions that implement the semaphore management.]

  Description []

  Authors     [Ralf Seepold]

******************************************************************************/
#ifndef MY_SEMAPHORE_H
#define MY_SEMAPHORE_H

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/stat.h>		// some makros used like O_CREAT
#include <sys/sem.h>


#define PERM_SEMAPHORE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH ) 

   struct MySemaphore {
      union {
         int sem_id;		// used for System V
         void *sem_ptr;	// only needed for POSIX semaphores not used here!
      } sem;
   };
   
   typedef struct MySemaphore MySemaphore;
 
   /*
		Functions
	*/  
	
   int createSem ( MySemaphore*, long );
   
   int waitSem ( int );
	
   int releaseSem ( int );
	
   void closeRemoveSem ( long );
	
   int getSemId ( long );
		
#endif /* MY_SEMAPHORE_H  */


