Q. Consider the following four processes with arrival times (in milliseconds) and their length of CPU bursts (in milliseconds) as shown below:
Process | P1 | P2 | P3 | P4 |
Arrival time | 0 | 1 | 3 | 4 |
CPU burst time | 3 | 1 | 3 | Z |
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
Ans:
This is the Gantt chart till time = 4 units
At this point P4 arrives with burst ‘Z’ & P3 is in queue with burst 3.
P1 & P2 have executed with P1 incurred delay 1unit & P2 0units.
Hence, Avg = 0+1+x/4 =1
⇒ x=3, the next delay should be 3. It would happen if assume Z=2.
It executes and completes at 6.
P3 will wait totally for 3units.
Hence, Avg=1.
z=2