This commit is contained in:
Eric Buxkemper 2015-11-06 12:53:20 -06:00
commit 950ec22244
4 changed files with 26 additions and 8 deletions

View file

@ -1,10 +1,17 @@
#include "semaphore.h"
#include "BoundedBuffer.h"
//#include "semaphore.h"
//#include <stdio>
#include <string>
#include <vector>
void BoundedBuffer::push(string item){
empty.P();
empty->P();
data.push_back(item);
full.V();//increment the number of full slots now.
full->V();//increment the number of full slots now.
}
void BoundedBuffer::pop(){

View file

@ -1,9 +1,15 @@
#ifndef _BoundedBuffer_H_
#define _BoundedBuffer_H_
#include <vector>
#include <string>
//#include <semaphore.h>
using namespace std;
unsigned int n = 20, b = 100, w = 5;
extern unsigned int n, b, w;
class BoundedBuffer{
@ -20,9 +26,9 @@ class BoundedBuffer{
void push(string item);
void pop();
//can't be larger than b strings
//b = user input
};
#endif

View file

@ -8,5 +8,9 @@ reqchannel.o: reqchannel.h reqchannel.cpp
dataserver: dataserver.cpp reqchannel.o
g++ -std=c++11 -g -o dataserver dataserver.cpp reqchannel.o -lpthread
simpleclient: simpleclient.cpp reqchannel.o
g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o
simpleclient: simpleclient.cpp reqchannel.o BoundedBuffer.cpp
g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o BoundedBuffer.cpp
clean:
$(RM) *.o

View file

@ -44,8 +44,6 @@ using namespace std;
/* CONSTANTS */
/*--------------------------------------------------------------------------*/
// unsigned int n = 20, b = 100, w = 5;
/* -- (none) -- */
/*--------------------------------------------------------------------------*/
@ -62,6 +60,9 @@ int main(int argc, char * argv[]) {
int option = -1;
unsigned int n;
unsigned int b;
unsigned int w;
while ((option = getopt(argc, argv, "n:b:w:")) != -1){
switch (option){
case 'n' :