-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRR_psuedo.txt
94 lines (63 loc) · 1.87 KB
/
RR_psuedo.txt
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
85
86
87
88
89
90
91
92
93
94
not running, grab next to run in ready:
calculate cpu burst time after time slice
if (cpu burst time - time_slice < 0){
curr.time = system_time + cpu burst time
cpu burst time = 0
}
else {
cpu burst time -= time slice
curr.time = system_time + time_slice
}
print
cpu finished:
if cpu burst time is not 0:
calculate next time slice finish time
if (cpu burst time - time_slice < 0){
curr.time = system_time + cpu burst time
cpu burst time = 0
}
else {
cpu burst time -= time slice
curr.time = system_time + time_slice
}
add to ready
if cpu burst time is 0, switch to io (regular cpu finish)
->
while cpu burst time is not 0
if (cpu burst time - time_slice < 0){
curr.time = system_time + cpu burst time
cpu burst time = 0
print
}
else {
cpu burst time -= time slice
curr.time = system_time + time_slice
print
}
if (ready empty) continue
if cpu burst time is not 0
add to ready
break
if cpu burst time is 0:
switch to io
cpu finished:
if no more remaining time:
completed cpu
switching to io
else
caclaulate next slice
io finished:
no change?
arrived:
no change
time 841ms: Process A0 started using the CPU for remaining 1192ms of 1448ms burst [Q A2 A1]
- store original, compare
grab next in ready:
if original == -1, set original to cpu burst time
if not equal to original:
started using for remaining of original
else:
started using the CPU
do time slice until ready is not empty
add time slice anyways?
if task is time slice, and queue is empty, then treat it like it never preempted? (subtract context switch?)