-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.c
48 lines (45 loc) · 913 Bytes
/
benchmark.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
#include "types.h"
#include "user.h"
int number_of_processes = 10;
int main(int argc, char *argv[])
{
int j;
for (j = 0; j < number_of_processes; j++)
{
int pid = fork();
if (pid < 0)
{
printf(1, "Fork failed\n");
continue;
}
if (pid == 0)
{
volatile int i;
for (volatile int k = 0; k < number_of_processes; k++)
{
if (k <= j)
{
sleep(200); //io time
}
else
{
for (i = 0; i < 100000000; i++)
{
; //cpu time
}
}
}
printf(1, "Process: %d Finished\n", getpid());
exit();
}
else{
;
// set_priority(100-(20+j),pid); // will only matter for PBS, comment it out if not implemented yet (better priorty for more IO intensive jobs)
}
}
for (j = 0; j < number_of_processes+5; j++)
{
wait();
}
exit();
}