-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgraph_plot.c
52 lines (50 loc) · 1.01 KB
/
graph_plot.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
#include "types.h"
#include "user.h"
int number_of_processes = 7;
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;
volatile int k;
for (k = 0; k < number_of_processes; k++)
{
if ((k+j) % 2)
{
sleep(20); //io time
}
else
{
for (i = 0; i < 100000000; i++)
{
; //cpu time
for (i = 0; i < 100000000; i++)
{
; //cpu time
for (i = 0; i < 100000000; i++)
{
; //cpu time
}
}
}
}
}
exit();
}
}
for (j = 0; j < number_of_processes; j++){
int wtime; int rtime;
//int pid =
waitx(&wtime, &rtime);
// printf(1,"%d has waiting ticks = %d && running ticks = %d\n",pid, wtime, rtime);
}
exit();
}