Preemptive Scheduling
-
- The currently running process may be interrupted and moved to the ready state by the OS.
- The resources (mainly CPU cycles) are allocated to the process for the limited amount of time and then is taken away, and the process is again placed back in the ready queue if that process still has CPU burst time remaining.
-
- That process stays in ready queue till it gets next chance to execute.
- The decision to preempt may be performed when,
- A new process arrives (with a higher priority than the current process)
Preemptive Scheduling
-
- An interrupt occurs (fairness)
- Periodically based on clock interrupt. (Eg: Round Robin)
Advantages of Preemptive scheduling
- More robust, one process cannot monopolize the CPU.
- Fairness. The OS makes sure that CPU usage is the same by all running process.
Disadvantages of Preemptive scheduling
- Context switch cost: Time taken by the scheduler to suspend the running task, switch the context, and dispatch the new incoming task.