V4
This commit is contained in:
parent
8735d45f39
commit
38443df097
2 changed files with 17 additions and 9 deletions
|
@ -1,15 +1,21 @@
|
|||
|
||||
#include <vector>
|
||||
|
||||
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<string> 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
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Reference in a new issue