In: Computer Science
Describe the difference between pre-emptive and non-pre-emptive scheduling algorithms. Which one is more suitable for a time sharing system and why?
PRE-EMPTIVE SCHEDULING:
In the pre-emptive scheduling, a process is interrupted while it is in the running state and a higher priority process is assigned in place of it. The scheduler puts the running process from the running state to the ready state. Sometimes if a higher priority process comes from the waiting state to a ready state then also preemption occurs. In pre-emptive scheduling, there is an overhead of switching the processes in-between known as context switching. Some of the examples of pre-emptive scheduling are shortest job first(SJF) preemptive, Round Robin(RR), etc.
NON-PRE-EMPTIVE SCHEDULING:
In non-pre-emptive scheduling, a process is not interrupted when it is in the running state and it is only switched with another process if it has terminated or has come to waiting state to perform some I/O operations. Hence, there is no overhead of context switching in this case. Some of the examples of non-pre-emptive scheduling are First Come First Serve(FCFS), shortest job first(SJF) non-preemptive, etc.
Obviously, pre-emptive scheduling is suitable for time-sharing as a process needs to be preempted in its running state whenever its allocated time has been completed and next process should be allocated to the CPU just like Round Robin scheduling algorithm.