1.7k views

An operating system used Shortest Remaining System Time first (SRT) process scheduling algorithm. Consider the arrival times and execution times for the following processes:

$$\begin{array}{|c|c|c|} \hline \textbf{Process} & \textbf{Execution Time} & \textbf{Arrival Time} \\\hline \text{P1} & 20 & 0 \\ \text{P2} & 25 & 15 \\ \text{P3} & 10 & 30 \\ \text{P4} & 15 & 45 \\\hline \end{array}$$

What is the total waiting time for process $P2$ ?

1. $5$
2. $15$
3. $40$
4. $55$
edited | 1.7k views

Waiting time for process $P2 =$ Completion time $–$ Arrival time $–$ burst time $= 55 – 15 – 25 = 15$

edited
–2
Ans should be A)..

@Gate Keeda- why process P2 will preempt? At 30 th time both P2 and P3 have same remaining time,  CPU will not switch to P3. it continue executing P2..right?
0

No.At time 30th both do not have same remaining time. P3 has 10 and P2 has 15. Check that again to make sure.

+1

Could anyone explain why the process is pre-empted ? IS SRT pre-emptive if not mentioned ?

EDIT  : SRTN is pre emptive form of SJF

http://www.moreprocess.com/process-2/shortest-job-first-sjf-shortest-remaining-time-next-srtn-scheduling-algorithm

0
Process is executed on the basis of their remaining time in execution  ...

For process $P2$ :
\begin{align*} \text{Waiting Time} &= \text{TAT} - \text{BT}\\ &= \left ( \text{CT-AT}\right) - BT \\ &= \left( 55 - 15 \right ) - 25 \\ &= 15 \end{align*}

we can solve using this way

0
Total waiting time and waiting time are same thing or different????

1
2