Merge branch 'master' of https://github.tamu.edu/ebuxkemper/CSCE314-MP4
This commit is contained in:
commit
950ec22244
4 changed files with 26 additions and 8 deletions
|
@ -1,10 +1,17 @@
|
||||||
|
|
||||||
|
#include "semaphore.h"
|
||||||
|
#include "BoundedBuffer.h"
|
||||||
|
//#include "semaphore.h"
|
||||||
|
//#include <stdio>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
void BoundedBuffer::push(string item){
|
void BoundedBuffer::push(string item){
|
||||||
|
|
||||||
empty.P();
|
empty->P();
|
||||||
data.push_back(item);
|
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(){
|
void BoundedBuffer::pop(){
|
||||||
|
|
|
@ -1,9 +1,15 @@
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef _BoundedBuffer_H_
|
||||||
|
#define _BoundedBuffer_H_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
//#include <semaphore.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
unsigned int n = 20, b = 100, w = 5;
|
extern unsigned int n, b, w;
|
||||||
|
|
||||||
class BoundedBuffer{
|
class BoundedBuffer{
|
||||||
|
|
||||||
|
@ -21,8 +27,8 @@ class BoundedBuffer{
|
||||||
|
|
||||||
void pop();
|
void pop();
|
||||||
|
|
||||||
|
|
||||||
//can't be larger than b strings
|
//can't be larger than b strings
|
||||||
//b = user input
|
//b = user input
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
8
makefile
8
makefile
|
@ -8,5 +8,9 @@ reqchannel.o: reqchannel.h reqchannel.cpp
|
||||||
dataserver: dataserver.cpp reqchannel.o
|
dataserver: dataserver.cpp reqchannel.o
|
||||||
g++ -std=c++11 -g -o dataserver dataserver.cpp reqchannel.o -lpthread
|
g++ -std=c++11 -g -o dataserver dataserver.cpp reqchannel.o -lpthread
|
||||||
|
|
||||||
simpleclient: simpleclient.cpp reqchannel.o
|
simpleclient: simpleclient.cpp reqchannel.o BoundedBuffer.cpp
|
||||||
g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o
|
g++ -std=c++11 -g -o simpleclient simpleclient.cpp reqchannel.o BoundedBuffer.cpp
|
||||||
|
|
||||||
|
clean:
|
||||||
|
$(RM) *.o
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,6 @@ using namespace std;
|
||||||
/* CONSTANTS */
|
/* CONSTANTS */
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// unsigned int n = 20, b = 100, w = 5;
|
|
||||||
|
|
||||||
/* -- (none) -- */
|
/* -- (none) -- */
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
@ -62,6 +60,9 @@ int main(int argc, char * argv[]) {
|
||||||
|
|
||||||
int option = -1;
|
int option = -1;
|
||||||
|
|
||||||
|
unsigned int n;
|
||||||
|
unsigned int b;
|
||||||
|
unsigned int w;
|
||||||
while ((option = getopt(argc, argv, "n:b:w:")) != -1){
|
while ((option = getopt(argc, argv, "n:b:w:")) != -1){
|
||||||
switch (option){
|
switch (option){
|
||||||
case 'n' :
|
case 'n' :
|
||||||
|
|
Reference in a new issue