# GATE Papers >> CSE >> 2017 >> Question No 24

Question No. 24

Considrer the following CPU processes with arrival times (in miliseconds) and length of CPU bursts (in miliseconds) as given below:

 Process Arrival time Burst time P1 0 7 P2 3 3 P3 5 5 P4 6 2

If the pre-emptive shortest remaining time first scheduling algorithm is used to schedule the processes, then the average waiting time across all processes is _________ milliseconds.

##### Answer : 3.0 to 3.0

Solution of Question No 24 of GATE 2017 CSE Paper

Using premptive SRTF algorithm Gantt chart will be,

$\begin{array}{l}{\mathbf{Turnaround}\boldsymbol\;\mathbf{time}}\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\mathbf{Waiting}\boldsymbol\;\mathbf{time}\\{\mathrm P}_1\rightarrow12-0=12\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm P}_1\rightarrow12-7=5\\{\mathrm P}_2\rightarrow6-3=3\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm P}_2\rightarrow3-3=0\\{\mathrm P}_3\rightarrow17-5=12\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm P}_3\rightarrow12-5=7\\{\mathrm P}_4\rightarrow8-6=12\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;{\mathrm P}_4\rightarrow2-2=0\end{array}$

Average Waiting Time $\frac{5+0+7+0}4=3.0$