# Where to start on SJF Cpu schedualing homework problem?

So the question is;

For the following three jobs: P1: 10 (3,2,5); P2: 4 (2,2); P3: 16 (2,3,5,6) Execute the three jobs using Exp Ave Alpha =0.6, default=2

I know the formula to get the exponential average for a process is

Pn+1 = (alpha) * Tn + (1-alpha * Pn)

I am basically confused at where to start. Obviously, the value .6 gets plugged in for the alpha, but where does the 2 go in the formula? And with each iteration is N increased? Where do the first time quantum for each process (3, 2, 2) go into the equation?

I have searched all over the web for an explanation, but every video I see on SJF has a gant chart and is given arrival time and looks nothing like this problem.

• Where did you encounter this problem? Do you have a textbook? Lecture notes? I would expect the algorithm to be described in the course materials, so reviewing them to see if there's something specific you don't understand would be a natural place to start.
– D.W.
Jul 7, 2017 at 22:58
• I am rewatching the lectures right now to see if I missed something. (I must have because I feel like I am missing something.) Jul 7, 2017 at 23:06
• Don't guess how to plug values in the formula. Understand what the formula means and why it is true. Once you've cleared that hurdle, you will be able to figure out how to use it in a particular case. Jul 8, 2017 at 5:12

Alright, so after reviewing with the professor, this is how this actually works.

The default of 2 means they all have an equal priority and just get run in order; process P1, P2, and P3.

Now, once we see P1 run for 3 quantums after the first burst, then we calculate its new prediction.

(0.6) * 2 [original default] + (0.4) * 3 [last run] = 1.2 + 1.2 = Prediction of 2.4

Same thing with P2 & P3 (both have a first burst of 2 quantums.)

(0.6) * 2 [original default] + (0.4)* 2 [last run] = 1.2 + 0.8 = Prediction of 2.0

So for the next quantums' order, it would be P2, P3, THEN P1.

Then after that run you would just do;

(0.6) * [2nd to last burst] + (0.4) * [last burst] = new prediction to figure out which proces would run next.

So the actual order would be;

Quantum: Process

Q3: P1:3

Q5: P2:2

Q7: P3:2

Q8: P2:2 (FINISHES)

Q12: P3:3

Q14: P1:2

Q19: P3:5

Q24: P1:5 (FINISHES)

Q30: P3:6 (FINISHES)