Processor Scheduling (SJF / FCFS) 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 &amp;P_2 &amp;P_3 \\
\hline
0-5 &amp;5-8 &amp;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 &amp;P_3 &amp;P_2 \\
\hline
0-5 &amp;5-6 &amp;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
- &amp;P_2 &amp;P_3 &amp;P_1 \\
\hline
0-2 &amp;2-5 &amp;5-6 &amp;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 &amp;P_2 &amp;P_2 &amp;P_3 &amp;P_1 \\
\hline
0-0.4 &amp;0.4-3 &amp;3-3.4 &amp;3.4-4.4 &amp;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. 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 &amp;P_2 &amp;P_3 &amp;P_2 &amp;P_1 \\
\hline
0-1.4 &amp;1.4-3 &amp;3-4 &amp;4-5.4 &amp;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