-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrequest.h
55 lines (42 loc) · 1.15 KB
/
request.h
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
#ifndef __REQUEST_H__
void requestHandle(int fd);
pthread_cond_t cond;
pthread_mutex_t lock;
pthread_cond_t blockcond;
int queue_capacity;
int currently_running;
/* ----------- QUEUE STUFF ------------*/
// Queue Policy
typedef enum Policy {block, dt, dh, bf, dynamic, randomPolicy} Policy;
typedef struct Node{
struct Node* next;
int request;
struct timeval arrivalTime;
struct timeval dispatchTime;
} Node;
typedef struct Queue{
Node* head;
int size;
Policy policy;
int dynamicSize;
} Queue;
Node* createNode(int item, struct timeval arrivalTime);
void enqueue(Queue* waitingQueue, int item);
Node* dequeue(Queue* waitingQueue);
void initQueue(Queue* queue);
void queueRemove(Queue* queue, int index);
Node* getNodeByCurrentThread();
/* ----------- STATISTICS STUFF ------------*/
typedef struct ThreadStat{
pthread_t thread;
int index;
Node* currentRequest;
int requestCounter;
int dynamicCounter;
int staticCounter;
} ThreadStat;
/* ----------- GLOBAL VARIABLES ------------*/
Queue* waitingQueue;
ThreadStat* threadPool;
int numOfThreads;
#endif