Consider three CPU-intensive processes, which require 10, 20 and 30 time units and arrive at times 0, 2 and 6, respectively. How many context switches are needed if the operating system implements a shortest remaining time first scheduling algorithm? Do not count the context switches at time zero and at the end.
Explanation: Let three process be P0, P1 and P2 with arrival times 0, 2 and 6 respectively and CPU burst times 10, 20 and 30 respectively. At time 0, P0 is the only available process so it runs. At time 2, P1 arrives, but P0 has the shortest remaining time, so it continues. At time 6, P2 arrives, but P0 has the shortest remaining time, so it continues. At time 10, P1 is scheduled as it is the shortest remaining time process. At time 30, P2 is scheduled. Only two context switches are needed. P0 to P1 and P1 to P2.
Quiz of this Question
- Operating Systems | CPU Scheduling | Question 4
- Operating Systems | CPU Scheduling | Question 2
- Operating Systems | Memory Management | Question 4
- Operating Systems | CPU Scheduling | Question 1
- Operating System | Process Management | CPU Scheduling
- Using fork() to produce 1 parent and its 3 child processes
- Get to know Ubuntu 18.04 LTS | Welcome Bionic Beaver!!
- Operating System | Allocation of frames
- Why Is There a system32 Folder in a 64-bit Operating System?
- ISRO | ISRO CS 2017 | Question 65