Preemptive Scheduling
Preemptive scheduling is used when a process switches from the running state to the ready state or from the waiting state to the ready state. The resources (mainly CPU cycles) are allocated to the process for a limited amount of time and then 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 the ready queue till it gets its next chance to execute.
Algorithms based on preemptive scheduling are Round Robin (RR), Shortest Remaining Time First (SRTF), Priority (preemptive version), etc.
Preemptive scheduling has a number of advantages and disadvantages. The following are preemptive scheduling’s benefits and drawbacks:
Advantages
- Because a process may not monopolize the processor, it is a more reliable method.
- Each occurrence prevents the completion of ongoing tasks.
- The average response time is improved.
- Utilizing this method in a multi-programming environment is more advantageous.
- The operating system makes sure that every process using the CPU is using the same amount of CPU time.
Disadvantages
- Limited computational resources must be used.
- Suspending the running process, change the context, and dispatch the new incoming process all take more time.
- The low-priority process would have to wait if multiple high-priority processes arrived at the same time.
Preemptive and Non-Preemptive Scheduling
Prerequisite – CPU Scheduling
You will discover the distinction between preemptive and non-preemptive scheduling in this article. But first, you need to understand preemptive and non-preemptive scheduling before going over the differences.