Operating System - Preemptive vs Non-Preemptive Scheduling
In process scheduling, the operating system decides which process gets the CPU and for how long. This decision can be made in two ways: preemptive or non-preemptive scheduling.
1. Preemptive Scheduling
Definition:
In preemptive scheduling, the CPU can be taken away from a running process if a higher-priority process arrives or its time slice expires.
Key Features:
-
OS has full control over CPU.
-
Ensures responsiveness for interactive systems.
-
Allows context switching between processes.
Examples of Preemptive Algorithms:
-
Round Robin (RR)
-
Shortest Remaining Time First (SRTF)
-
Priority Scheduling (Preemptive)
2. Non-Preemptive Scheduling
Definition:
In non-preemptive scheduling, once a process starts executing, it runs to completion or until it voluntarily yields the CPU (e.g., for I/O).
Key Features:
-
Simpler to implement.
-
No context switching overhead.
-
Less CPU control by OS.
Examples of Non-Preemptive Algorithms:
-
First-Come, First-Served (FCFS)
-
Shortest Job First (SJF) – Non-preemptive
-
Priority Scheduling (Non-preemptive)