/************************************************************ File: gsemaphore.h Description: A program that simulates a dependancy graph for a set of threads. The declaration and functions for a general semaphore. Author: Dana Vrajitoru Organization: IUSB Date: November 24, 2004 **************************************************************/ #ifndef GSEMAPHORE_H #define GSEMAPHORE_H #include struct Gsemaphore { int value; pthread_mutex_t mutex; }; // Assigns the value of the second parameter to the internal semaphore // value and initializes the mutex. void Init_sem(Gsemaphore &sem, int val); // Waits until the value has become 0, then increments it. It's a // blocking function. void Test_and_inc(Gsemaphore &sem); // Decreases the value of the semaphore without testing it. void Dec(Gsemaphore &sem); #endif