• edited by
21,746 views
45 45 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 P_1 & 0 & 2 & 1 & 5 &3 \\\hline P_2 & 2 & \text{3 (lowest)}& 3 & 3 & 1 \\\hline  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}$

7 Answers

Best answer
60 60 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 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 6 votes

Grant chat:-

Answer:
Position:
Show:

Related questions

55 55 votes
4 answers 4 answers
16.9k
16.9k views
Ishrat Jahan asked Oct 31, 2014
16,912 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 frames.It ...
31 31 votes
2 answers 2 answers
10.7k
10.7k views
Ishrat Jahan asked Nov 1, 2014
10,683 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 ...
53 53 votes
6 answers 6 answers
21.7k
21.7k views
Ishrat Jahan asked Oct 31, 2014
21,682 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 ini...
47 47 votes
3 answers 3 answers
20.3k
20.3k views
Ishrat Jahan asked Oct 31, 2014
20,289 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 system?It is a multiprogramme...