-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfcfs2.txt
54 lines (37 loc) · 814 Bytes
/
fcfs2.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
FCFS:
tasks priority_queue
ready queue
initialize tasks with all the arrival times
while (tasks OR ready not empty):
if task is empty:
add front of ready
grab next task in tasks
if task is cpu finished:
add back to task its io finish time
grab next in ready, calculate its cpu finish and add to tasks
else if task is arrival:
add to ready queue
else if task is io finished:
move index
add to ready queue
arrival
cpu -> io -> back to ready
^
add next ready
FCFS2:
if not running and ready not empty:
run the next in ready
grab next task
if task is done (index is beyond its burst time)
continue
if cpu done:
running = false
update system_time
switch to io
if io done:
increment index
update system_time
add to ready
if arrival:
update system_time
add to ready