Add process-scheduling tag.

Dark Mode

7,197 views

11 votes

Consider the following set of processes, assumed to have arrived at time $0$. Consider the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR, assume that the processes are scheduled in the order$P_1, P_2, P_3, P_4$.

$\begin{array}{|l|l|l|l|l|} \hline \text{Processes} & P_1 & P_2 & P_3 & P_4 \\ \hline \text{Burst time (in ms)} &8 & 7 & 2 & 4 \\ \hline \end{array}$

If the time quantum for RR is $4$ ms, then the absolute value of the difference between the average turnaround times (in ms) of SJF and RR (round off to $2$ decimal places is_______

$\begin{array}{|l|l|l|l|l|} \hline \text{Processes} & P_1 & P_2 & P_3 & P_4 \\ \hline \text{Burst time (in ms)} &8 & 7 & 2 & 4 \\ \hline \end{array}$

If the time quantum for RR is $4$ ms, then the absolute value of the difference between the average turnaround times (in ms) of SJF and RR (round off to $2$ decimal places is_______

11 votes

Best answer

**SJF:**

$$\small \begin{array} {|c|c|c|c|} \hline \textbf{Process} & \textbf{Burst Time} & \textbf{Completion Time} & \textbf{Turn Around Time} \\\hline P_{1} & 8 & 21 & 21 \\ P_{2} & 7 & 13 & 13 \\ P_{3} & 2 & 2 & 2 \\ P_{4} & 4 & 6 & 6 \\\hline \end{array}$$Average Turn-Around Time $: \frac{21+13+2+6}{4}= 10.5$

**RR:**

$$\small \begin{array} {|c|c|c|c|} \hline \textbf{Process} & \textbf{Burst Time} & \textbf{Completion Time} & \textbf{Turn Around Time} \\\hline P_{1} & 8 & 18 & 18 \\ P_{2} & 7 & 21 & 21 \\ P_{3} & 2 & 10 & 10 \\ P_{4} & 4 & 14 & 14 \\\hline \end{array}$$Average Turn-Around Time $: \frac{18+21+10+14}{4}= 15.75$

**Absolute Difference **$= \mid 10.5 - 15.75 \mid = 5.25.$

6 votes

Answer : 5.25

**Since arrival time of all process is same =0, So turn around time = finish time**

For SJF :

Process | Burst Time | Completion Time | Turn Around Time |
---|---|---|---|

P1 | 8 | 21 | 21 |

P2 | 7 | 13 | 13 |

P3 | 2 | 2 | 2 |

P4 | 4 | 6 | 6 |

Average Turn Around Time using SJF : $\frac{21+13+2+6}{4}$= 10.5

For RR(4 Time quantum):

Process | Burst Time | Completion Time | Turn Around Time |
---|---|---|---|

P1 | 8 | 18 | 18 |

P2 | 7 | 21 | 21 |

P3 | 2 | 10 | 10 |

P4 | 4 | 14 | 14 |

Average Turn Around Time using RR :$\frac{18+21+10+14}{4}$= 15.75

Absolute Difference = 15.75 - 10.5= 5.25