From 38443df0970d022cd4378cf9e50847e3a05c4aaa Mon Sep 17 00:00:00 2001 From: Eric Buxkemper Date: Fri, 6 Nov 2015 11:56:25 -0600 Subject: [PATCH] V4 --- BoundedBuffer.h | 18 ++++++++++++------ simpleclient.cpp | 8 +++++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/BoundedBuffer.h b/BoundedBuffer.h index 9a2e73d..5d18136 100755 --- a/BoundedBuffer.h +++ b/BoundedBuffer.h @@ -1,15 +1,21 @@ +#include + +using namespace std; + +unsigned int n = 20, b = 100, w = 5; class BoundedBuffer{ - Semaphore full(0); //initialized to 0, Since there are 0 full slots - Semaphore empty(b); //initialized to b, Since all the slots are empty - Semaphore mutex(0); + //int b; + Semaphore *full = new Semaphore(0); //initialized to 0, Since there are 0 full slots + Semaphore *empty = new Semaphore(b); //initialized to b, Since all the slots are empty + Semaphore *mutex = new Semaphore(1); + - int b; vector data; - BoundedBuffer( + //BoundedBuffer( void set_b(int val_b){ b = val_b;} @@ -20,5 +26,5 @@ class BoundedBuffer{ //can't be larger than b strings //b = user input -} +}; diff --git a/simpleclient.cpp b/simpleclient.cpp index 4e7e0db..04d9e35 100755 --- a/simpleclient.cpp +++ b/simpleclient.cpp @@ -30,6 +30,7 @@ #include "reqchannel.h" #include "semaphore.h" +#include "BoundedBuffer.h" using namespace std; @@ -43,6 +44,8 @@ using namespace std; /* CONSTANTS */ /*--------------------------------------------------------------------------*/ +// unsigned int n = 20, b = 100, w = 5; + /* -- (none) -- */ /*--------------------------------------------------------------------------*/ @@ -56,8 +59,7 @@ using namespace std; /*--------------------------------------------------------------------------*/ int main(int argc, char * argv[]) { - - unsigned int n = 20, b = 100, w = 5; + int option = -1; while ((option = getopt(argc, argv, "n:b:w:")) != -1){ @@ -74,7 +76,7 @@ int main(int argc, char * argv[]) { } } - cout << n << b << w << endl; + cout << "TEST: " << n << b << w << endl; Semaphore sema(5); cout << "CLIENT STARTED:" << endl;