Last Updated : 26 Oct, 2018

Calculate the average waiting time for the following processes:

Process ID Arrival Time Bust Time
P1 5 7
P2 2 9
P3 0 5
P4 0 3
P5 1 8
P6 15 25

Consider the preemptive shortest job first scheduling algorithm and all the time in nanoseconds.

(A) 7.10 ns
(B) 7.12 ns
(C) 7.16 ns
(D) None of these.


Answer: (C)

Explanation: Using preemptive shortest job first scheduling algorithm, Gantt chart will be
\"\"

Since, Turn Round Time = Completion time – arrival time, so

P1 = 12 - 5 = 7
P2 = 29 - 2 = 27
P3 = 5 - 0 = 5
P4 = 3 - 0 = 3
P5 = 20 - 1 = 19
P6 = 54 - 15 = 39 

And, Waiting time = Turn around time – burst time, so

P1 =  7 - 7 = 0
P2 = 27 - 9 = 18
P3 = 5 - 5  = 0
P4 = 3 -3 = 0
P5 = 19 - 8 = 11
P6 = 39 - 25 = 14 

Process ID Arrival Time Bust Time Turn Arround Time Waiting Time
P1 5 7 7 0
P2 2 9 27 18
P3 0 5 5 0
P4 0 3 3 0
P5 1 8 19 11
P6 15 25 39 14

Hence,

Average waiting time  
= (18 + 11 +14 ) / 6 = 7.16 ns 

So, option (C) is correct.

Quiz of this Question


Share your thoughts in the comments