Problem Statement
Explain the difference between preemptive and non-preemptive CPU scheduling with examples.
Explanation
In preemptive scheduling the operating system can interrupt a running process (for example when its time slice expires or a higher priority process arrives) and switch to another process. For instance, Round Robin and priority with preemption are preemptive algorithms. Non-preemptive scheduling means once a process starts running it will continue until it finishes or blocks for I/O; the OS does not forcibly take the CPU away. First-Come-First-Served (FCFS) and non-preemptive SJF are examples. Preemptive gives better responsiveness but adds overhead from context switches; non-preemptive is simpler but may lead to worse response times and poor handling of interactive tasks.
