//created by Dr. Ramsey on 10/25 #include "semaphore.h" #include "fcntl.h" #include using namespace std; int main() { char *name ="rams"; //open a named semaphore and create if it wasn't created //0644 describes the permissions //1 is the initial value of the semaphore sem_t *sem = sem_open(name,O_CREAT, 0644, 1); sem_post(sem); //the usual add 1 sem_wait(sem); //the usual wait until we can subtract 1 sem_close(sem); //disconnect this process from the semaphore //get rid of this semaphore sem_unlink(name); //will destroy if all are closed }