Skip to main content

GATE CSE 2017Operating System › CPU SchedulingVerified

GATE CSE 2017 PYQ: Consider the set of process with arrival time (in milliseonds), CPU burst time (in millisecods) and priority…

Consider the set of process with arrival time (in milliseonds), CPU burst time (in millisecods) and priority (0 is the highest priority)  shown below. None of the process have I/O burst timeProcessArrival TimeBurst TimePriorityP10112P25280P31223P42101P59164\small \begin{array}{|c|c|c|c|} \hline \textbf{Process} & \textbf{Arrival Time} & \textbf{Burst Time} & \textbf{Priority} \\\hline \text{}P_1 & 0 & 11 & 2 \\\hline \text{}P_2 & 5 & 28 & 0 \\\hline \text{}P_3 & 12 & 2 & 3 \\\hline \text{}P_4 & 2 & 10 & 1\\\hline \text{}P_5 & 9 & 16 & 4 \\\hline \end{array}The average waiting time (in milli seconds) of all the process using premtive priority scheduling algorithm is ______

    Answer

    29

    Approach

    Simulate preemptive priority scheduling where a smaller priority number means higher priority. Track the CPU timeline, preempting the running process whenever a newly arrived process has a strictly higher priority. Then compute waiting time for each process as completion time minus arrival time minus burst time, and average over all five processes.

    The preemptive priority simulation gives completion times P1=49, P2=33, P3=51, P4=40, P5=67. Using total waiting time = sum(CT) - sum(AT) - sum(BT) = 240 - 28 - 67 = 145, the average waiting time is 145/5 = 29 ms.

    Reviewed by GateIQ Editorial Team: IIT & IISc Alumni.