What are the key differences between preemptive and non-preemptive scheduling algorithms in process management? Provide examples of scenarios where each might be used.
The key differences between preemptive and non-preemptive scheduling algos are:-
Preemptive scheduling algorithm:-
In preemptive scheduling algorithm, the process is interrupted before the completion of process task.
Starvation occurs after adding a high priority process to the queue.
CPU utilization is high in preemptive scheduling.
Resources are allocated here for a limited time.
For example, suppose certain processes are running in a system where each process is allocated a specific time period of 10 ms, if a process takes more time than that, that process is preempted, and the next one is scheduled.
Non-preemptive scheduling algorithm:-
In a non-preemptive scheduling algorithm, a process is not interrupted until its task are finished.
CPU utilization is low.
The CPU does not allow other processes to utilize resources until one has completed execution.
Resources are allocated until the task is done.
For example, suppose there's certain process waiting to be executed, they will be executed in the first come first serve basis, and each process would be allowed to execute until it finishes its task despite its priority.