edited by
12,805 views
30 votes
30 votes

The arrival time, priority, and duration of the CPU and I/O bursts for each of three processes $P_1, P_2 $ and $P_3$ are given in the table below. Each process has a CPU burst followed by an I/O burst followed by another CPU burst. Assume that each process has its own I/O resource.$$\small \begin{array}{|c|c|c|c|c|c|} \hline \textbf{Process} & \textbf{Arrival} & \textbf{Priority}& \textbf{Burst duration} & \textbf{Burst duration} & \textbf{Burst duration) }\\& \textbf{Time} & & \textbf{(CPU)} & \textbf{(I/O)} & \textbf{(CPU) }
\\\hline \text{$P_1$} & 0 & 2 & 1 & 5 &3 \\\hline \text{$P_2$} & 2 & \text{3 (lowest)}& 3 & 3 & 1 \\\hline  \text{$P_3$} & 3 & \text{1 (highest)}& 2 & 3 & 1 \\\hline  \end{array}$$The multi-programmed operating system uses preemptive priority scheduling. What are the finish times of the processes $P_1, P_2 $ and $P_3$?

  1. $\text{11, 15, 9}$
  2. $\text{10, 15, 9}$
  3. $\text{11, 16, 10}$
  4. $\text{12, 17, 11}$
edited by

4 Answers

Best answer
43 votes
43 votes

GIVEN : assuming that each process has its own i/o resource.

(GANTT CHART FOR I/O OF PROCESSOR $\mathbf{P_1, P_2 ,P_3}$)

EXPLANATION :

Here, $P_2$ has the least priority and $P_1$ has the highest.

$P_1$ enters CPU at $0$ and utilizes it for $1$ time unit. Then it performs i/o for $5$ time units.

Then $P_2$ enters at time unit $2$ and requires $3$ time units of CPU. But $P_3$ whose priority is greater than $P_2$ arrives at time unit $3$.

So, $P_2$ IS PREEMPTED (only $1$ unit of $P_2$ is done out of $3$ units. Therefore $2$ units of $P_2$ are left out) AND $P_3$ ACQUIRES THE CPU. Once $P_3$ finishes, $P_2$ enters the CPU to complete its pending $2$ units job at time unit $5$. AGAIN BY THEN $P_1$ finishes its i/o and arrives with a higher priority. Therefore of $2$ units $P_2$ performs only one unit and the CPU is given to $P_1$.Then when $P_1$ is performing in CPU, $P_3$ completes its i/o and arrives with a higher priority.Thus the CPU is given to $P_3$ ($1$ UNIT IS USED). $\mathbf{P_3}$ FINISHES AT TIME UNIT 9. NOW PRIORITY OF $P_1$ IS MORE THAN $P_2$, SO, CPU IS USED BY $P_1$. $\mathbf{P_1}$ FINISHES BY TIME UNIT 10. THEN CPU IS  ALLOCATED FOR PROCESS $P_2$. $\mathbf{P_2}$ PERFORMS REST OF ITS WORK AND FINISHES AT TIME UNIT 15.

THEREFORE,

 FINISH TIME OF $P_1,P_2,P_3$ ARE $10,15$ AND $9$ RESPECTIVELY. 😊

Correct Answer: $B$

edited by
20 votes
20 votes
0---p1----1--- no process---2---p2---3----p3----5----p2---6----p1----8----p3---9----p1----10----p2----11---no process----14--p2---15

From time  1 to 6 p1 is doing i/o

From time 5 to 8 p3 is doing i/o

P2 is doing i/o from11 to 14

So finishing time of p1 p2 p3 are 10 15 9

Ans is b
6 votes
6 votes

Grant chat:-

6 votes
6 votes

People having trouble understanding refer this pipeline way-

Answer:

Related questions

29 votes
29 votes
2 answers
4