#ifndef _countsem_h #define _countsem_h #include // This is a counting semaphore implementation // Caution: This should only be used // by threads class CountingSemaphore { public: CountingSemaphore(int ini_value=0); ~CountingSemaphore(); void P(void); void V(void); void SetVal(int num); private: int count; pthread_cond_t c; pthread_mutex_t c_m; pthread_mutex_t m; }; #endif