Fixed compilation errors.
This commit is contained in:
parent
2b113344a3
commit
b2e95401be
3 changed files with 15 additions and 7 deletions
|
@ -1,5 +1,7 @@
|
|||
|
||||
#include "semaphore.h"
|
||||
#include "BoundedBuffer.h"
|
||||
//#include "semaphore.h"
|
||||
//#include <stdio>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
@ -14,10 +16,10 @@ 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(){
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
|
||||
|
||||
#ifndef _BoundedBuffer_H_
|
||||
#define _BoundedBuffer_H_
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <semaphore.h>
|
||||
//#include <semaphore.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
unsigned int n = 20, b = 100, w = 5;
|
||||
extern unsigned int n, b, w;
|
||||
|
||||
class BoundedBuffer{
|
||||
//int b;
|
||||
Semaphore full(); //initialized to 0, Since there are 0 full slots
|
||||
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);
|
||||
|
||||
|
@ -29,3 +33,4 @@ class BoundedBuffer{
|
|||
//b = user input
|
||||
};
|
||||
|
||||
#endif
|
|
@ -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' :
|
||||
|
|
Reference in a new issue