-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbounded.h
More file actions
37 lines (25 loc) · 812 Bytes
/
bounded.h
File metadata and controls
37 lines (25 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//===========================================================================//
// Project: Projekat iz Operativnih sistema 1
// File: bounded.h
// Date: Maj 2021
// Opis: Kruzni ograniceni bafer sa sinhronizacijom;
//
//===========================================================================//
#ifndef _OS1_BOUNDED_BUFFER_
#define _OS1_BOUNDED_BUFFER_
#include <semaphor.h>
class BoundedBuffer {
public:
BoundedBuffer (unsigned size);
virtual ~BoundedBuffer ();
int append (char);
char take ();
int fullCount(){return itemAvailable.val();}; // potrebno consumeru
private:
unsigned Size;
Semaphore mutexa, mutext;
Semaphore spaceAvailable, itemAvailable;
char* buffer;
int head, tail;
};
#endif // _OS1_BOUNDED_BUFFER_