What are Preemptive and Non-Preemptive CPU scheduling?

Non-Preemptive Scheduling :

  • In non-preemptive scheduling, once the CPU has been allocated to a process, the process keeps the CPU until it releases the CPU either by terminating or by switching to the waiting state.

e.g. FCFS, SJF CPU Scheduling.

Preemptive SchedulingĀ :

  • Under this, the process may release the resources or CPU when it switches from the running state to the ready state (for example, when an interrupt occurs) or from the waiting state to the ready state (for example, at completion of I/O).
  • ItĀ can result in race conditions when data are shared among several processes. Consider the case of two processes that share data. While one process is updating the data, it is preempted so that the second process can run. The second process then tries to read the data, which are in an inconsistent state.

e.g. SRTF, Round Robin CPU Scheduling

Leave a Reply

Your email address will not be published. Required fields are marked *