-
Notifications
You must be signed in to change notification settings - Fork 0
/
scheduler.c
54 lines (42 loc) · 1.12 KB
/
scheduler.c
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
#include "headers.h"
#include "scheduler.h"
#include "stack.h"
int main(int argc, char *argv[])
{
int algo = atoi(argv[1]);
int msgq_id;
schedulerInitialize(algo, &msgq_id);
msgBuf msgq_buffer;
int now, previous_time = -1;
printf("msgq_id= %d\n", msgq_id);
fflush(stdout);
while (1)
{
now = getClk();
if(getMessage(msgq_id,&msgq_buffer)==false) {
}
else {
CreateProcess(&msgq_buffer);
while(getMessage(msgq_id,&msgq_buffer))
{
CreateProcess(&msgq_buffer);
}
if(now > previous_time) {
stackRefresh();
}
schedulerIsForContextSwitch();
if(now > previous_time) {
previous_time = now;
}
}
if(now > previous_time) {
stackRefresh();
schedulerIsForContextSwitch();
previous_time = now;
}
}
// TODO implement the scheduler :)
// upon termination release the clock resources.
destroyClk(true);
return 0;
}