Here is a comparison of Preemptive and Non-Preemptive Algorithms in CPU Scheduling in Operating System:
Feature | Preemptive Scheduling | Non-Preemptive Scheduling |
---|---|---|
Definition | A scheduling algorithm in which the operating system can interrupt a running process and allocate the CPU to another process with higher priority. | A scheduling algorithm in which once a process has been allocated the CPU, it continues to run until it terminates or blocks on I/O. |
Priority | Processes with higher priority are given priority over processes with lower priority. | Processes are given the CPU for a defined time slice or until they complete execution. |
Interruptions | Processes can be interrupted at any time by the operating system. | Processes cannot be interrupted until they complete execution or block on I/O. |
Context Switching | Context switching occurs more frequently in preemptive scheduling, leading to higher overhead. | Context switching occurs less frequently in non-preemptive scheduling, leading to lower overhead. |
Response Time | Preemptive scheduling provides a better response time for high priority tasks, as they get to run more frequently. | Non-preemptive scheduling can result in poor response time for high priority tasks, as they have to wait for lower priority tasks to complete. |
Latency | Preemptive scheduling can result in lower latency for high priority tasks, as they get to run more frequently. | Non-preemptive scheduling can result in higher latency for high priority tasks, as they have to wait for lower priority tasks to complete. |
CPU Utilization | Preemptive scheduling can result in better CPU utilization, as the CPU is shared among multiple processes. | Non-preemptive scheduling can result in lower CPU utilization, as the CPU is not shared among processes. |
Real-Time Systems | Preemptive scheduling is used in real-time systems to meet critical deadlines. | Non-preemptive scheduling is not used in real-time systems, as it cannot guarantee predictable execution times. |
User Perception | Preemptive scheduling provides a better user experience, as high priority tasks get executed quickly. | Non-preemptive scheduling can result in a poor user experience, as high priority tasks can take longer to complete. |
Throughput | Preemptive scheduling can result in higher throughput, as the CPU is shared among multiple processes. | Non-preemptive scheduling can result in lower throughput, as the CPU is not shared among processes. |
System Performance | Preemptive scheduling can result in better system performance, as the CPU is used efficiently and effectively. | Non-preemptive scheduling can result in lower system performance, as the CPU is not used as efficiently. |
CPU Scheduling Overhead | Preemptive scheduling has higher overhead due to the frequent context switching. | Non-preemptive scheduling has lower overhead, as there is less frequent context switching. |
Starvation | Preemptive scheduling can result in starvation of low priority tasks, as they may never get a chance to run. | Non-preemptive scheduling can prevent starvation, as all tasks get a chance to run eventually. |
Predictability | Preemptive scheduling provides less predictability, as the execution order of tasks can change dynamically. | Non-preemptive scheduling provides more predictability, as the execution order of tasks is defined and does not change dynamically. |