2k views

Consider the following table of arrival time and burst time for three processes $P0, P1$ and $P2.$

 Process Arrival Time Burst Time $P0$ $0$ ms $9$ ms $P1$ $1$ ms $4$ ms $P2$ $2$ ms $9$ ms

The pre-emptive shortest job first scheduling algorithm is used. Scheduling is carried out only at arrival or completion of processes. What is the average waiting time for the three processes?

1. $5.0$ ms
2. $4.33$ ms
3. $6.33$ ms
4. $7.33$ ms
edited | 2k views

Answer is (A). $5$ms

Gantt Chart

$\text{ Average Waiting Time = } \dfrac{(0+4)+(0)+(11)}{3} = \text{ 5ms. }$

edited by
+3

Scheduling is carried out only at arrival or completion of processes

Doesn't this statement mean non-pre emptiveness? Even though question asks us to calculate using the pre-emptive shortest job first scheduling algorithm. Blockquoted text confuses me. I even tried with non pre emptive scheduling and I get answer as 6.33ms (C). Could some one help me understand?

0
"Scheduling is carried out only at arrival or completion of processes"

Doesn't this statement mean non-pre emptiveness
0
Yes, that is what is done here! At time 0, only P0 is there which has a burst of 9units and is taken into execution. At time 1, P1 arrives whose BT is 4 which is less than P0's(8 now), hence P0 is pre empted and so on
0

@Shalini Dutta , what do you think of this statement,

"Scheduling is carried out only at arrival or completion of processes"

+6
yes , which means scheduling is carried out only when a process arrives/completes. By my explanation P0 os pre empted when P1 arrives(Note : arrival OR completion)
0
Thanks for the clarification. I misunderstood it.
0
"Scheduling is carried out only at arrival 'or' completion of processes".
It may seems like this statement makes the question about non preemptive shortest job first scheduling algo but the difference is made by "or" statement.
Tricked
0
Why is P0 scheduled in the 5th sec? Are we calculating the shortest job at a particular instant?(then it will be shortest remaining time first)

Can someone explain why P2 cannot be scheduled in 5th sec?(considering both P0 and P2 have same bursts times initially) I think both schedules are possible as it is not mentioned what happens on ties. Pls help.
0
@Manoja, yes, initially both processes $P_{0}$ and  $P_{2}$ have same burst time but process $P_{0}$ got processor between time $0$ ms to $1$ ms ...So, at time = $5$ ms , remaining burst time of $P_{0}$ is $8$ ms which is less than the burst time of process $P_{2}$ which is $9$ ms.

1
2