Question
Consider the following set of processes, assumed to have arrived at time 0. Consider the CPU scheduling algorithms Shortest Job First (SJF) and Round Robin (RR). For RR, assume that the processes are scheduled in the order .
| Processes | P1 | P2 | P3 | P4 |
|---|---|---|---|---|
| Burst time (in ms) | 8 | 7 | 2 | 4 |
If the time quantum for RR is 4 ms, then the absolute value of the difference between the average turnaround times (in ms) of SJF and RR (round off to 2 decimal places) is _______.
Official answer and solution
- Official answer
- 5.25
- From
- Official GATE 2020 answer key
Solution
Construct Gantt charts for SJF and Round Robin (quantum 4) and calculate average turnaround times.
Given processes arriving at time 0:
- : burst time = 8 ms
- : burst time = 7 ms
- : burst time = 2 ms
- : burst time = 4 ms
Shortest Job First (SJF) scheduling:
- Order of execution by shortest burst time: .
- Gantt chart:
[P3: 0-2] [P4: 2-6] [P2: 6-13] [P1: 13-21]. - Completion times: .
- Turnaround times (): .
- Average TAT for SJF:
Round Robin (RR) scheduling with time quantum 4 ms:
- Ready queue initially: .
- runs from 0 to 4 ms (remaining: 4 ms). Ready queue: .
- runs from 4 to 8 ms (remaining: 3 ms). Ready queue: .
- runs from 8 to 10 ms (remaining: 0 ms, completes at ). Ready queue: .
- runs from 10 to 14 ms (remaining: 0 ms, completes at ). Ready queue: .
- runs from 14 to 18 ms (remaining: 0 ms, completes at ). Ready queue: .
- runs from 18 to 21 ms (remaining: 0 ms, completes at ).
- Completion times: .
- Average TAT for RR:
Absolute difference:
5.25
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2020 Computer Science and Information Technology (CS)
- Question
- 60 of 65, printed as CS Q.50
- 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.