Shortest Job First Scheduling

Suppose that following processes arrive for the execution at the times indicated. Each process will run the listed amount of time.

Process [Arrival Time(ms) , Burst Time(ms)]
A[0 , 5] , B[3 , 5] , C[5 , 3] , D[7 , 2]

I want to draw Gantt chart and calculate average waiting time for preemptive Shortest Job First Scheduling.

Solution

http://imgur.com/fP8u61C

Waiting Time is 2ms.

Just Please tell me if this is correct.

The step where I have doubt is that at 3ms when process B arrives, will the scheduler complete the process A or start process B.


Yes, your answer is correct. In fact the problem as posed is ambiguous, but both possibilities give the same answer.

First, the ambiguity : Shortest Job First scheduling is not usually considered preemptive. The preemptive variant is called Shortest Remaining Time First Scheduling (see for instance the Shortest Job Next entry on Wikipedia. However, your exercice states "preemptive Job First scheduling", and that's ambiguous...

Second, however, the only time when there might be a difference between these two scheduling policies is, as you mentioned, at t=3 when both A and B are eligible. But if the scheduling is non-preemptive, of course A continues to execute. It it's preemptive, we must consider the remaining time : A has 2 ms left while B has its whole 5... so A still gets the CPU.

Finally, the waiting times are : A -> 0 ms, B -> 7 ms, C -> 0 ms, D -> 1ms , the average of which is indeed 2 ms .


You probably have to do on your own your homework.

Show your try on that and say what are you questions and your issues.

Don't wait for a complete ready solution!

链接地址: http://www.djcxy.com/p/84860.html

上一篇: OS时间安排程序

下一篇: 最短的Job First Scheduling