00001 00005 #ifndef _SEMA_H 00006 #define _SEMA_H 00007 #include "phil.h" 00008 00009 00010 00024 typedef struct PhilSemaphore 00025 { 00026 volatile int counter; 00027 PhilMutex lock; 00028 PhilCond queue; 00029 } PhilSemaphore; 00030 00031 00032 00033 /*************************************************** 00034 * pour creer un semaphore 00035 ***************************************************/ 00036 extern int PhilSemaphoreInit(PhilSemaphore * s, int i ); 00037 extern int PhilSemaphoreDestroy(PhilSemaphore * s); 00038 /*************************************************** 00039 * faire un P ou V sur un semaphore 00040 ***************************************************/ 00041 extern int PhilSemaphoreP( PhilSemaphore * s ); 00042 extern int PhilSemaphoreV( PhilSemaphore *s ); 00043 00044 #endif