in Operating System edited by
2,019 views
3 votes
3 votes

​​​​Consider a single processor system with four processes $\text{A, B, C,}$ and $\text{D}$, represented as given below, where for each process the first value is its arrival time, and the second value is its $\text{CPU}$ burst time.

                  $\mathrm{A}(0,10), \mathrm{B}(2,6), \mathrm{C}(4,3)$, and $\mathrm{D}(6,7)$.

Which one of the following options gives the average waiting times when preemptive Shortest Remaining Time First $\text{(SRTF)}$ and Non-Preemptive Shortest Job First $\text{(NP-SJF)}$ $\text{CPU}$ scheduling algorithms are applied to the processes?

  1. $\mathrm{SRTF}=6, \mathrm{NP}-\mathrm{SJF}=7$
  2. $\mathrm{SRTF}=6, \mathrm{NP}-\mathrm{SJF}=7.5$
  3. $\mathrm{SRTF}=7, \mathrm{NP}-\mathrm{SJF}=7.5$
  4. $\mathrm{SRTF}=7, \mathrm{NP}-\mathrm{SJF}=8.5$
in Operating System edited by
by
2.0k views

3 Answers

1 vote
1 vote

Here, AT = Arrival Time, BT = Burst Time, CT = Completion Time, TAT = Turn-around Time, WT = Waiting Time

TAT = CT - AT

WT = TAT - BT

----------------------------------------------------------------------------------------------------------------------------------------------------------

SRTF: Avg WT = 6

----------------------------------------------------------------------------------------------------------------------------------------------------------

SJF: Avg WT = 7.5

--------------------------------------------------------------------------------------------------------------------------------------------------------

So Answer is Option B.

edited by
0 votes
0 votes
A
0 votes
0 votes

$\textbf{SJF CPU scheduling:}$

$$\small \begin{array}{|c|c|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time}& \textbf{Burst Time} & \textbf{Completion Time}&\textbf{Turn AroundTime} &\textbf{WaitingTime}  \\\hline \text{A} & 0 & 10 &10&10&0 \\ \text{B} & 2 & 6&19&17&11 \\ \text{C} & 4 & 3&13&9&6 \\ \text{D} & 6 & 7&26&20&13 \\\hline  \end{array}$$

$\text{Total average waiting time SJF=$\frac{0+11+6+13}{4}=\frac{30}{4}=7.5$}$

$\textbf{SRTF CPU scheduling:}$

$$\small \begin{array}{|c|c|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time}& \textbf{Burst Time} & \textbf{Completion Time}&\textbf{Turn AroundTime} &\textbf{WaitingTime}  \\\hline \text{A} & 0 & 10 &26&26&16 \\ \text{B} & 2 & 6&11&9&3 \\ \text{C} & 4 & 3&7&3&0\\ \text{D} & 6 & 7&18&12&5 \\\hline  \end{array}$$

$\text{Total average waiting time SRTF=$\frac{16+3+0+5}{4}=\frac{24}{4}=6$}$
Note:
  • Turnaround time is calculated as (Burst time -arrival time)
  • Waiting time is calculated as (Turnaround time-Burst time )
Option $(B)$ is correct.

Answer:

Related questions