Consider three CPU intensive processes, which require 10, 20, 30 units and arrive at times 0,2,6 respectively. How many context switches are needed if shortest remaining time first is implemented? Context switch at 0 is included but context switch at end is ignored
Consider three CPU intensive processes, which require 10, 20, 30 units and arrive at times 0,2,6 respectively. How many context switches are needed if shortest remaining time first is implemented? Context switch at 0 is included but context switch at end is ignored Correct Answer 3
Scheduling Algorithm:
shortest remaining time first
Gantt chart:
|
P1 |
P2 |
P3 |
0 10 30 60
Process table:
|
Process Id |
Arrival Time (AT) |
Burst Time (BT) |
Completion Time (CT) |
|
1 |
0 |
10 |
10 |
|
2 |
2 |
20 |
30 |
|
3 |
6 |
30 |
60 |
[ alt="F1 R.S 6.8.20 Pallavi D1" src="//storage.googleapis.com/tb-img/production/20/08/F1_R.S_6.8.20_Pallavi_D1.png" style="width: 179px; height: 104px;">
Number of context switches = 2
Since initial is included
Therefore total context switches = 1 + 2 = 3
Important Points:
Context switch at 0 is included but context switch at end is ignored