Today we will solve and discuss about CPU Scheduling, but about SJF non-preemptive. We still use request table has been used in chapter 1.


Question 1: Use SJF algorithm to find the completing time of P3 ?

You must attend to the question that teacher give you. If it not say anything about preemptive or non-preemptive, that it’s mean you have to use non-preemptive! I have been written many article about this thing – define and discuss about algorithms of CPU Scheduling – in website Thus, if you want me show you how to draw Gantt chart in this article! So tired.sjf

Ok, we got it. Look at this, you can understand something, right? In the table of request, you just draw the first process at the head, following is the list process was sorted from min to max Burst Time. Yes! That it!

After you drawn the chart, everything has become easily. Now, you can find the completing time of P3 like this below:

cau 1 sjf.jpg

Question 2: Follow the SJF algorithm, find the average completing time?

This question so insance! Use the trick I gave you yesterday, we will find out:

P1 = 7 ms

P2 = 36 – 1 = 35 ms

P3 = 20 – 3 = 17 ms

P4 = 12 – 4 = 8 ms

P5 = 9 – 2 = 7 ms

And now, the final number we get:

cau 2 sjf.jpg

Question 3: Give the correct number of average waiting time, just use SJF?

Waiting time? Ah, we you the the number on the left edge and minus it to the arrival time.

P1 = 0 ms

P2 = 20 – 1 = 19 ms

P3 = 12 – 3 = 9 ms

P4 = 9 – 4 = 5 ms

P5 = 7 – 2 = 5 ms

Here you are, sweet bunny:

cau 3 sjf.jpg