edited by
13,255 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
44 votes
44 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

11.1k
views
5 answers
40 votes
Ishrat Jahan asked Oct 31, 2014
11,063 views
In the working-set strategy, which of the following is done by the operating system to prevent thrashing?It initiates another process if there are enough extra ... total number of available frames.I onlyII onlyNeither I nor IIBoth I and II
6.7k
views
2 answers
27 votes
Ishrat Jahan asked Nov 1, 2014
6,694 views
The wait and signal operations of a monitor are implemented using semaphores as follows. In the following,$x$ is a condition variable,mutex is a semaphore initialized to $1$,$x$_sem is ... $P(x\_sem), V(x\_sem)$
14.0k
views
5 answers
38 votes
Ishrat Jahan asked Oct 31, 2014
13,979 views
Consider the solution to the bounded buffer producer/consumer problem by using general semaphores $S, F,$ and $E$. The semaphore $S$ is the mutual exclusion semaphore initialized ... (I) only(II) onlyNeither (I) nor (II)Both (I) and (II)
11.9k
views
2 answers
29 votes
Ishrat Jahan asked Oct 31, 2014
11,946 views
The process state transition diagram of an operating system is as given below.Which of the following must be FALSE about the above operating ... preemptive schedulingIt uses non-preemptive schedulingIt is a multi-user operating system