edited by
5,376 views
27 votes
27 votes

We wish to schedule three processes $P1$, $P2$ and $P3$ on a uniprocessor system. The priorities, CPU time requirements and arrival times of the processes are as shown below.
$$\begin{array}{|c|c|c|c|} \hline \textbf{Process} & \textbf{Priority} & \textbf{CPU time} & \textbf{Arrival time}\\
&  & \textbf{required} & \textbf{(hh:mm:ss)}
\\\hline \text{P1} & \text{10 (highest)} & 20\text{ sec} &  00:00:05 \\\hline \text{P2} & 9 & 10 \text{ sec}&  00:00:03 \\\hline \text{P3} & \text{8 (lowest)} & 15 \text{ sec}&  00:00:00 \\\hline  \end{array}$$

We have a choice of preemptive or non-preemptive scheduling. In preemptive scheduling, a late-arriving higher priority process can preempt a currently running process with lower priority. In non-preemptive scheduling, a late-arriving higher priority process must wait for the currently executing process to complete before it can be scheduled on the processor.
What are the turnaround times (time from arrival till completion) of $P2$ using preemptive and non-preemptive scheduling respectively?

  1. $30$ sec, $30$ sec
  2. $30$ sec, $10$ sec
  3. $42$ sec, $42$ sec
  4. $30$ sec, $42$ sec
edited by

1 Answer

Best answer
34 votes
34 votes

Answer will be (D).

TAT = Completion Time - Arrival Time.

The Gannt Chart for Non Preemptive scheduling will be $(0)P3,(15)P1,(35)P2(45).$

From above this can be inferred easily that completion time for $P2$ is $45$, for $P1$ is $35$ and $P3$ is $15.$

Gantt Chart for Preemptive-  $(0)P3,(1)P3,(2)P3,(3)P2,(4)P2,(5)P1,(25)P2,(33)P3(45)$.

Similarly take completion time from above for individual processes and subtract it from the Arrival time to get TAT.

edited by
Answer:

Related questions