retagged by
28,733 views
40 votes
40 votes
Consider the following four processes with arrival times (in milliseconds) and their length of CPU bursts (in milliseconds) as shown below:
$$\begin{array}{|c|c|c|c|c|} \hline \text{Process} & P1 & P2 & P3 & P4  \\ \hline \text{Arrival Time} & 0 & 1 & 3 & 4 \\ \hline \text{CPU burst time} & 3 & 1 & 3 & Z \\ \hline \end{array}$$
These processes are run on a single processor using preemptive Shortest Remaining Time First scheduling algorithm. If the average waiting time of the processes is $1$ millisecond, then the value of $Z$ is _____
retagged by

4 Answers

Best answer
48 votes
48 votes

Till $t = 4$, the waiting time of $P1 = 1$ and $P2 = 0$ and $P3=1$ but $P3$ has not started yet.

Case $1:$

Note that if $P4$ burst time is less than $P3$ then $P4$ will complete and after that $P3$ will complete. Therefore Waiting time of $P4$ should be $0$. And total waiting time of $P3 = 1 +$ ( Burst time of $P4$) because until $P4$ completes $P3$ does not get a chance.

Then average waiting time $= \frac{1+0+(1+x)+0}{4} = 1$

$\frac{2+x}{4} = 1 \Rightarrow x = 2.$

Case $2:$

Note that if $P4$ burst time is greater than $P3$ then $P4$ will complete after $P3$ will complete. Therefore, Waiting time of $P3$ remains the same. And total waiting time of $P4 =$ ( Burst time of $P3$) because until $P3$ completes $P4$ does not get a chance.

Then average waiting time $= \frac{1+0+1+3}{4} = 1$

$\frac{5}{4} \neq 1 \Rightarrow$ This case is invalid.

Correct Answer: 2

edited by
24 votes
24 votes
In SRTF we use criteria on the basis of burst time . A process have lowest burst time go first  for execution  if two process have same burst time priority should be given to that process which have lowest arrival time . Still two process have same arrival time choose lower  process id.

 

14 votes
14 votes

Ans: Z=2

$1)\ if\ BT(P3)<BT(P4)$

  Completion Time (CT) Turn around time (TAT) Waiting time (WT)
P1 4 4 1
P2 2 2 0
P3 7 4 1
P4 7+Z 3+Z 3

$Avg\ WT=\dfrac{1+0+1+3}{4}=\dfrac{5}{4}$

$\dfrac{5}{4}\neq 1$

 

$2)\ if\ BT(P4)<BT(P3)$

  CT TAT(CT-AT) WT(TAT-BT)
P1 4 4 1
P2 2 1 0
P3 7+Z 4+Z Z+1
P4 4+Z Z 0

$Avg\ WT=\dfrac{1+0+(Z+1)+0}{4}=\dfrac{Z+2}{4}$

$\dfrac{Z+2}{4}=1$

$Z=2$

1 votes
1 votes
The burst time of process P4=2

i.e,Z=2

Since,waiting time of process P1 and P2 are 1 and 0 respectively and finishes in time 4ms and given the average=1 therefore the sum of waiting time of P3 and P4 must be 3 and for this,Z should be equal to 2 so that the waiting time of P4 could be 0 and waiting time of P3 will be 6-3=3ms
Answer:

Related questions

18 votes
18 votes
4 answers
1
20 votes
20 votes
4 answers
2
26 votes
26 votes
4 answers
3
Arjun asked Feb 7, 2019
19,280 views
Consider the following matrix:$R = \begin{bmatrix} 1 & 2 & 4 & 8 \\ 1 & 3 & 9 & 27 \\ 1 & 4 & 16 & 64 \\ 1 & 5 & 25 & 125 \end{bmatrix}$The absolute value of the product ...