Repository navigation
Expand file tree
/
Copy pathThreadManagerBase.h
More file actions
84 lines (49 loc) · 1.36 KB
/
Copy pathThreadManagerBase.h
File metadata and controls
84 lines (49 loc) · 1.36 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef SKI_LIFT_THREADSTATW_H
#define SKI_LIFT_THREADSTATW_H
#include "QueueElement.h"
#include "MessageType.h"
#include <pthread.h>
#include <vector>
using namespace std;
class ThreadManagerBase {
protected:
int rank;
int size;
int myWeight;
int clock;
char *processorName;
vector<int> tabAcks;
vector<QueueElement> queue;
pthread_mutex_t clockMutex;
pthread_cond_t conditionalMutex;
public:
//TODO Move something to protected section
static const int MSG_SIZE = 2;
static const int CAPACITY = 200;
ThreadManagerBase(int rank, int size, char processorName[]);
int getSize();
vector<QueueElement> &getQueue();
vector<int> &getTabAcks();
void initTabAcks();
void increaseClock();
void updateClock(int receivedClock);
int *constructMessage();
void sendMessageForEverybody(int *msg, MessageType type);
void addOwnRequestToQueue();
void addRequestToQueue(QueueElement element);
void sortQueue();
bool isEveryAck();
bool isEnoughPlaceOnLift();
void clearAcks();
void removeYourselfFromQueue();
int getSumOfACks();
void lock();
void unlock();
void wait();
void signal();
virtual ~ThreadManagerBase();
void removeFromQueueById(int id);
string toString();
void sleepRandomTime();
};
#endif //SKI_LIFT_THREADSTATW_H