5 Three tasks, A, B and C are run concurrently on a computer system. • Task A ar
ID: 3828744 • Letter: 5
Question
5 Three tasks, A, B and C are run concurrently on a computer system. • Task A arrives first at time 0, and uses the CPU for 50 ms before finishing. • Task B arrives shortly after A, still at time 0. Task B loops 4 times; for each iteration of the loop, B uses the CPU for 2 ms and then it does I/O for 8 ms. • Task C is identical to B, but arrives shortly after B, still at time 0.
Assuming there is no overhead to doing a context switch, identify when A, B and C will finish for each of the following CPU scheduling disciplines.
(a) First-Come-First-Serve (b) Round robin with a 1ms time slice (c) Round robin with a 100ms time slice (d) Multilevel feedback with four levels, and a time slice for the highest priority level is 1ms (e) Shortest job first?
Explanation / Answer
a) First Come First Serve :
A comes first, then B, then C.
So, A will do first then B then C
0 <- --- A -----> 50 <----- 4 loops of B(each 2) ----> 58 (B goes to I/o) <----- 4 loops of C(each 2)-----> 66(C goes for I/o)
A finishes : 50
B finishes : 58+8 for I/O = 66.
C finishes : 66+8 = 74 for I/O
b) Round Robin with time slice 1
0 <--A--> 1 <---B---> 2 <---C--->3 <--A--> 4 <---B---> 5 <---C--->6 <--A--> 7 <---B---> 8 <---C--->9 <--A--> 10 <---B---> 11 <---C--->12 <--A--> 13 <---B---> 14 <---C--->15 <--A--> 16 <---B---> 17 <---C--->18 <--A--> 19 <---B---> 20 <---C--->21 <--A--> 22 <---B(goes to I/O)---> 23 <---C---> 24 (wait till B's completion) --> 66 (A finishes)
A finishes : 66
B finishes : 23+ 8 for I/O = 31
C finishes : 31+ 8 for I/O = 39
c) Round Robin with 100 ms
0 <- --- A -----> 50 <----- 4 loops of B(each 2) ----> 58 (B goes to I/o) <----- 4 loops of C(each 2)-----> 66(C goes for I/o)
A finishes : 50
B finishes : 58+8 for I/O = 66.
C finishes : 66+8 = 74 for I/O
d) multilevel feed back queue :
Similar to b) Round Robin with time slice 1
e) Shortest job first -considering without preempting
0 <------B(runs 4 loop) -------> 8(B goes for I/O) <--------- C(runs 4 loop) -----------> 16(goes for I/O) <----------A-----------
---> 66
A finishes : 66
B finishes: 8+8(I/O) = 16
C finishes: 16+ 8(I/O) = 24
if it is preemptive then
0 <----B----> 1 <------C-----> 2 <----B----> 3 <------C----->4 <----B----> 5 <------C----->6 <----B----> 7<------C----->8 <----B----> 9 <------C----->10 <----B----> 11 <------C----->12 <----B----> 13 <------C----->14 <----B----> 15 <------C-----> 16 <---A----> 66
B finishes: 15+8 = 23
C finishes : 23+ 8 = 31
A finishes: 66
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.