What is the difference between preemptive and non-preemptive scheduling?
a) Preemptive scheduling allows the OS to take control of the CPU from a running process, while non-preemptive scheduling does not
b) Non-preemptive scheduling is faster than preemptive scheduling
c) Preemptive scheduling only works in single-tasking systems
d) Non-preemptive scheduling only works for real-time processes
Answer:
a) Preemptive scheduling allows the OS to take control of the CPU from a running process, while non-preemptive scheduling does not
Explanation:
In preemptive scheduling, the operating system can interrupt a running process to assign the CPU to a higher-priority process. This allows the OS to manage process execution more dynamically, ensuring that critical tasks receive CPU time when necessary.
In non-preemptive scheduling, once a process is assigned to the CPU, it runs until it voluntarily relinquishes the CPU, either by terminating or switching to a waiting state. This approach is simpler but can lead to inefficiencies if lower-priority processes run for long periods.
Preemptive scheduling is commonly used in multitasking and real-time systems to ensure responsive performance, whereas non-preemptive scheduling is simpler and used in batch-processing environments.