From 6e3005d25a5cfbde7b11d91cb120160076cf55ad Mon Sep 17 00:00:00 2001 From: shadow8t4 Date: Thu, 5 Nov 2015 19:37:44 -0600 Subject: [PATCH] Fixed compiling errors. --- makefile | 9 +++------ semaphore.h | 15 +++++++++++---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/makefile b/makefile index 4aa7ca3..13e1369 100755 --- a/makefile +++ b/makefile @@ -3,13 +3,10 @@ all: dataserver simpleclient reqchannel.o: reqchannel.h reqchannel.cpp - #g++-4.7 -c -g reqchannel.cpp - g++ -std=c++11 -c -g reqchannel.cpp + g++ -std=c++11 -c -g reqchannel.cpp dataserver: dataserver.cpp reqchannel.o - #g++-4.7 -g -o - g++ -std=c++11 -g -odataserver dataserver.cpp reqchannel.o -lpthread + g++ -std=c++11 -g -o dataserver dataserver.cpp reqchannel.o -lpthread simpleclient: simpleclient.cpp reqchannel.o - #g++-4.7 -g -o simpleclient simpleclient.cpp reqchannel.o - g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o + g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o diff --git a/semaphore.h b/semaphore.h index 255f7df..6b9649c 100755 --- a/semaphore.h +++ b/semaphore.h @@ -22,7 +22,7 @@ /*--------------------------------------------------------------------------*/ #include -#include +//#include /*--------------------------------------------------------------------------*/ /* DATA STRUCTURES */ @@ -60,9 +60,16 @@ public: /* -- SEMAPHORE OPERATIONS */ int P(){ - Lock(); - - + //This is to lock the Semaphore. + pthread_mutex_lock( &m ); + + //Wait until condition, basically wait until signaled. + pthread_cond_wait( &c, &m ); + + //Some code here. + + //Unlock the Semaphore. + pthread_mutex_unlock( &m ); } //; int V();