How to calculate average waiting time in preemptive priority scheduling

processscheduling

Given the following table :

enter image description here

I want to calculate the average waiting time of preemptive priority scheduling .

In the table above , the bigger the number is (in the priority column) the higher the priority is .

Partial solution :

|p1|p3|p1|p2|p5|p4|
0  8  29 33 52 67 80

What do I do from here ?

Thanks

Best Answer

did you understand the partial solution (the actual schedule) you have posted?

Waiting time of a process = finish time of that process - execution time - arrival time

Once you have this for all process then just take the average. That would give you the avg waiting time of the scheduling algorithm for this instance

More details:

Here process p1 did not wait for the first 8 seconds. Then at t=9 it was preempted. It was in wait mode from time t=9 to t=29 while process p3 was executing. So p1 had waited for 21 seconds while p3 was executing. At t=29, p1 started again and completed at t=33. In total, p1 had waited for 21 seconds. As per the formula we get waiting time as 33-12-0=21. Basically for each process we look at the time between when it arrived and when it finished. Any time between this interval when it is not executing is a wait time

Related Topic