Question
Consider the following four processes with arrival times (in milliseconds) and their length of CPU bursts (in milliseconds) as shown below:
| Process | Arrival time | CPU burst time |
|---|---|---|
| P1 | 0 | 3 |
| P2 | 1 | 1 |
| P3 | 3 | 3 |
| P4 | 4 | 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 is ________.
Official answer and solution
- Official answer
- 2
- From
- Official GATE 2019 answer key
Solution
Construct the Gantt chart for Shortest Remaining Time First (SRTF) scheduling and solve for Z.
The processes, arrival times, and bursts are:
- : Arrival = , Burst =
- : Arrival = , Burst =
- : Arrival = , Burst =
- : Arrival = , Burst =
Let us trace SRTF scheduling step by step:
- At : Only has arrived (remaining burst = ). starts execution.
- At : arrives with burst . 's remaining burst is . Since 's remaining burst () is less than 's (), is preempted and runs.
- At : completes its burst of .
- Completion time of .
- Turnaround time of .
- Waiting time of .
resumes with remaining burst .
- At : arrives with burst . 's remaining burst is . Since , continues.
- At : completes its burst.
- Completion time of .
- Turnaround time of .
- Waiting time of .
At , arrives with burst . Ready queue holds (burst ) and (burst ).
We are given that the average waiting time is :
If , is dispatched before :
- runs from to . Completion time = .
- runs from to . Completion time = .
Sum of waiting times:
Checking consistency: , so is indeed scheduled before . Hence, .
2
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2019 Computer Science and Information Technology (CS)
- Question
- 51 of 65, printed as CS Q.41
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.