So I know that scheduling has been covered in other articles, but because my provided values are different and decimals are used, I am having difficulty wrapping my head around it. I have reviewed all of the other posts already but would like clarification on my specific values if possible.
- What is the average turnaround time for these processes with the FCFS scheduling algorithm?
- What is the average turnaround time for these processes with the nonpreemptive SJF scheduling algorithm?
- The SJF algorithm is supposed to improve performance, but notice that we chose to run process $P_1$ at time 0 because we did not know that two shorter processes would arrive soon. Compute what the average turnaround time will be if the CPU is left idle for the first 2 units and then nonpreemptive SJF scheduling is used. Remember that processes $P_1$ and $P_2$ are waiting during this idle time, so their waiting time may increase.
- What is the average turnaround time for these processes with the preemptive SJF scheduling algorithm?
The values (including a make-shift Gantt chart) are as follows:
1. FCFS
\begin{array} {|r|r|} \hline P_1 &P_2 &P_3 \\ \hline 0-5 &5-8 &8-9 \\ \hline \end{array}
Completion times:
$P_1=5, P_2=8,P_3=9$
Turnaround Time = 5.866667
2. Non-PreEmptive SJF
\begin{array} {|r|r|} \hline P_1 &P_3 &P_2 \\ \hline 0-5 &5-6 &6-9 \\ \hline \end{array}
Completion times:
$P_1=5, P_2=9, P_3=6$
Tunaround Time = 5.2
3. Future-Knowledge (Non-PreEmptive SJF with Idle time)
\begin{array} {|r|r|} \hline - &P_2 &P_3 &P_1 \\ \hline 0-2 &2-5 &5-6 &6-11 \\ \hline \end{array}
Completion times:
$P_1=11,P_2=5,P_3=6$
Turnaround Time = 6.2
4. PreEmptive SJF (SRTF)
\begin{array} {|r|r|} \hline P_1 &P_2 &P_2 &P_3 &P_1 \\ \hline 0-0.4 &0.4-3 &3-3.4 &3.4-4.4 &4.4-9 \\ \hline \end{array}
Completion times:
$P_1=9,P_2=4.4,P_3=3.4$
Turnaround Time = 4.133333333
Hopefully these values are correct. If they are not, could you please explain the process so that I can understand how to properly calculate it myself? Thank you in advance for any assistance!
1 Answer 1
1. FCFS
Turnaround Time T T = 5.866 is correct.
2. Non-PreEmptive SJF
T T = 5.2 is correct.
3. Future-Knowledge (Non-PreEmptive SJF with Idle time)
T T = 6.2, I'm not sure about this.
We never get a future knowledge of how big the next process will be.
4. PreEmptive SJF (SRTF)
Here, your scheduling is wrong.
$P_2$ arrives at time 1.4, how can you schedule it at time 0.4?
Refer below scheduling:
\begin{array} {|r|r|} \hline P_1 &P_2 &P_3 &P_2 &P_1 \\ \hline 0-1.4 &1.4-3 &3-4 &4-5.4 &5.4-9 \\ \hline \end{array}
T T ($P_1$) = 9 - 0=9
T T ($P_1$) = 5.4 - 1.4=4
T T ($P_1$) = 4 - 3 =1
Avg T T = 4.6
Dont you see the improved TT of one over other.
FCFS = 5.8> NON-PRE SJF = 5.2> PRE SJF =4.6
-
$\begingroup$ Thank you for the reply! I now see what I did wrong. I also recalculated and believe that SJF Non-Preemptive with an Idle time of 2 (question 3) is 5.866667. | P2 | P3 | P1 | 2----5----6----11 ? $\endgroup$asyncle– asyncle2016年10月27日 01:17:45 +00:00Commented Oct 27, 2016 at 1:17
-
$\begingroup$ @asyncle even if you introduce an idle time of two (TT=6.2), it doesn't give a better result than Non-pree SJF(TT=5.2) then whats the use on that idle time? $\endgroup$Alwyn Mathew– Alwyn Mathew2016年10月27日 03:57:13 +00:00Commented Oct 27, 2016 at 3:57
-
$\begingroup$ It's not any better. The end goal was to determine if it was any better. When the idle time is greater, the processor is potentially able to start with a lower burst time (in this example, it was able to start with process #2 which had a burst of three instead of process #1 which had a burst of 5 - even then, because of the idle time, the TT was still worse). $\endgroup$asyncle– asyncle2016年10月28日 13:34:27 +00:00Commented Oct 28, 2016 at 13:34