Operating System

What are preemptive and non- preemptive Scheduling ?

Preemptive scheduling 

Preemptive scheduling is a popular algorithm used in real-time systems. It involves prioritizing tasks and allocating CPU time to the highest priority task. If a higher priority task becomes ready to run, the CPU can be taken away from the current task. 

Here are some disadvantages of preemptive scheduling:

  • Memory-intensive: The scheduler must hold all context information for all tasks that it preempts.
  • Time-consuming: Context switching can be time-consuming. 

Preemptive scheduling is well-suited for real-time systems and environments where tasks with varying priorities must be handled. It ensures that the system can rapidly respond to time-critical tasks.

Preemptive scheduling is a scheduling discipline that allows the CPU to take away a process after it has been granted. 

Here are some examples of preemptive scheduling:

  • Round Robin: Each process executes for a fixed time interval, then other processes in the queue preempt it. The state of the preempted process is saved using context switching. Round Robin gives all processes equal priority and assigns them equal time periods.
  • Preemptive Priority Scheduling: The process with the highest priority is given the CPU next. For example, if Process P1 has a burst time of 1 unit and priority 2, it will be scheduled until the next job arrives or it completes, since no other process is available.
  • Shortest Remaining Time First: An example of preemptive scheduling .

 Non- preemptive Scheduling 

Non-preemptive scheduling is a type of scheduling algorithm that allows a process to run until it finishes or enters a wait state. During this time, the process cannot be interrupted. 

In non-preemptive scheduling, the average response time is poor. This is because each process must wait for all other processes to finish before it can access the CPU. 

Here are some other characteristics of non-preemptive scheduling:

  • Deadlock: Non-preemptive scheduling is associated with deadlock.
  • Priority scheduling: Priority scheduling is a non-preemptive algorithm that is commonly used in batch systems. In this algorithm, the scheduler selects tasks based on priority.
  • Multilevel queue scheduling: Multilevel queue scheduling can be either preemptive or non-preemptive, depending on the scheduling algorithm used in each queue. For example, a Round Robin algorithm is preemptive, whereas FirstCome, First Serve is non-preemptive. 

Here are some other examples of non-preemptive scheduling algorithms:

  • Non-preemptive priority scheduling: Schedules the process with the lowest arrival time first. If two or more processes have the lowest arrival time, they are scheduled according to their priority.
  • Non-preemptive shortest job first (SJF): An example of non-preemptive scheduling 

Preemptive scheduling is not better than non-preemptive scheduling, and vice versa.

Leave a Reply

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