# GATE2019-41

10.1k views
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 _____

edited
4
ans is 2
0
At, 4ms p1 and p2 are finished, and waiting time of p1 and p2 is 1 and 0. In order to have avg wait time as 1 sum of wait time of p3 and p4 should be 3. If p4 starts at 4 with BT as "2" then its wait time is 0, and at 6 ms it will be over and p3 will start at 6. So wait time of p3 is 6-3=3 and hence it satisfies the condition that sum of wait times of p3 and p4 should be 3. Hence, Z=2
1
Should be 2 !
7
I could not do this in exam, but solved it easily when came home. That's why we need to keep calm during GATE exam
0
Very easy question.

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.

edited
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.

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 vote
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

## Related questions

1
7.7k views
The following C program is executed on a Unix/Linux system : #include<unistd.h> int main() { int i; for(i=0; i<10; i++) if(i%2 == 0) fork(); return 0; } The total number of child processes created is ________________ .
Consider three concurrent processes $P1$, $P2$ and $P3$ as shown below, which access a shared variable $D$ that has been initialized to $100$ ... the minimum and maximum possible values of $D$ after the three processes have completed execution are $X$ and $Y$ respectively, then the value of $Y-X$ is ____
The index node (inode) of a Unix -like file system has $12$ direct, one single-indirect and one double-indirect pointers. The disk block size is $4$ kB, and the disk block address is $32$-bits long. The maximum possible file size is (rounded off to $1$ decimal place) ____ GB