2.3k 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 | 2.3k 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
+1

Can someone explain why P2 cannot be scheduled in 5th sec?

Understood my mistake: I took $P_1$ as $10$ initially.

Thank you @ankitgupta.1729

+1
@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.
+2

Scheduling is carried out only at arrival or completion of processes

this is what we do in preemptive mode ..schduling happens when new process comes( arrives) based on criteria.

In non preemptive mode ..scheduling happens only when process completes..process arrival in between doesn't affect

0
great observation.

1
2