Difference Between Preemptive and Non Preemptive Scheduling in Operating Systems

Edited by Diffzy | Updated on: April 30, 2023

       

Difference Between Preemptive and Non Preemptive Scheduling in Operating Systems

Why read @ Diffzy

Our articles are well-researched

We make unbiased comparisons

Our content is free to access

We are a one-stop platform for finding differences and comparisons

We compare similar terms in both tabular forms as well as in points


Introduction

An operating system often allocates the CPU to operations that must be carried out. Scheduling is a technique used to carry out this purpose. Pre-emptive and non-preemptive Scheduling are two different variants of the approach. Every process receives a set amount of CPU time in the first scenario. After that period, the procedure is replaced with another one waiting for the state.

On the other hand, the second style of Scheduling is known as non-pre-emptive Scheduling, and it only releases the CPU when the process has finished running. Pre-emptive Scheduling is a CPU scheduling method that allocates certain amounts of CPU time to specific interactions. While Non-Preemptive Scheduling is a CPU scheduling method, it accepts the asset and keeps it until the interaction ends or is sent to the holding upstate.

Pre-emptive vs Non-Pre-emptive Scheduling

Pre-emptive Scheduling, as the name implies, refers to Scheduling that takes place as a process transition from a running state to a ready state or from a waiting state to a ready state. This allocates the resources to run the task for a long time. The operation is then interrupted in the middle and moved to the ready queue with its bursts. There is still time, thus this procedure will wait till its turn to perform will come.

The CPU has been allotted to a specific process in this sort of scheduling approach. By changing context or ceasing to exist, the process that is using the CPU will release it.

It is the only approach that can be used on different hardware platforms. This is because, unlike pre-emptive Scheduling, it does not need specific hardware (such as a timer). When a process chooses to stop or enter the wait state, non-pre-emptive Scheduling takes place. Pre-emptive Scheduling involves allocating activities according to their demands. A specific interaction has been given the CPU's attention in the non-pre-emptive Scheduling. When an operator exits or goes into standby, non-pre-emptive Scheduling takes place. The action under Pre-emptive Scheduling is readily interruptible.

Difference Between Pre-emptive and Non-Pre-emptive in Tabular Form

Parameters of Comparison Pre-emptive Scheduling Non-Pre-emptive Scheduling
Basic A process is given the resources for a certain period. A process that has been given resources hangs onto them until the end of its burst time or until it enters the waiting state.
Interrupt A process may be stopped in the middle. Before it ends or enters the waiting stage, the process cannot be stopped.
Flexibility Because each task in the ready queue is given some CPU time, this kind of schedule is flexible. It is not flexible
Time Frame The processes are given time during pre-emptive scheduling for a brief duration. Non-pre-emptive scheduling assigns the task to the CPU, which will retain it there until it has finished running or switches from the ready state to the waiting state.
Cost The cost of proactive scheduling exists. Proactive scheduling has a price.
Examples Shortest Remaining Time First, Round Robin, etc. First Come First Serve, Shortest Job First, Priority Scheduling, etc.
CPU Allocation The CPU is given to the processes in this process for a certain amount of time. As long as the process is running, CPU is allotted to it until it finishes or enters the waiting state.
Interruption The cost of using a pre-emptive algorithm is that it must transfer the process from the ready state to the running state and back again. The overhead of transitioning the process from running into the ready state is not there with non-pre-emptive scheduling.
Starvation A low-priority process may starve if a high-priority process often enters the ready queue. Later processes with shorter CPU burst times may suffer if a process with a large burst time is using the CPU.

What is Pre-emptive Scheduling?

Whenever the CPU is in an inactive state, the CPU scheduler's job is to distribute a cycle to the CPU. The interaction is delegated to the CPU via the CPU scheduler, who selects a cycle from the prepared line. The resources (CPU Cycle) have been assigned to a process in this sort of schedule for a certain period. When a process is running, it may be stopped. The low-priority processes may starve if a high-priority process regularly appears in the "ready" queue. Due to the need to plan several processes, this kind of Scheduling incurs costs. When a cycle with a high need enters the prepared line, preplanned planning instructs stopping the operation with the low need and continuing the operation with the high need. Pre-emptive Scheduling allows us to take the CPU away from the running programs periodically. CPU is only given to a process for a predetermined amount of time, and after some time, whether the process has finished running or not, the CPU is taken back from the same time.

Pre-emptive Scheduling is the kind of schedule in which we can regain the CPU. Pre-emptive Scheduling is used in almost all of the scheduling methodologies we covered in this lesson, except for a handful. These examples include first come, first served, shortest task, shortest time to completion, and round robin scheduling approaches. When a process transitions from the running state to the ready state or from the waiting state to the ready state, pre-emptive Scheduling is employed. The resources, mostly CPU cycles, are given to the process for a certain period before being removed; if the process still has CPU burst time left, it is then put back in the ready queue. The process remains in the ready queue until it has its subsequent opportunity to run. Instead of what it intends to perform, it will break the cycle, stabilise the process, and begin the operation of the process with the highest priority. This enables the cycle to complete, which is more important than the other, and once the operation is accomplished, the next one will begin.

Therefore, in this manner, any operation that is on the available line is given the best chance to proceed. Operating systems (OS) use the method of pre-emptive Scheduling to increase the system's general responsiveness. Instead of waiting for them to execute in the forefront, the OS may make sure that these tasks are finished as soon as possible by anticipatorily scheduling them to run in the background. The distinction between pre-emptive and non-preemptive Scheduling is sometimes unclear. Pre-emptive multitasking, which was originally introduced in the early days of computers, is where this misconception originated.

A single application may operate in the background while other programs are visible on the computer screen thanks to pre-emptive multitasking. This made it possible for users to do many jobs at once.

What is Non-Pre-emptive Scheduling?

Once a process enters the running state in non-pre-emptive mode, it keeps going until it terminates, blocks to wait for input or output, or asks for an operating system service. Until a process is finished, it is not interrupted; only then does the CPU transition to another process. The only approach that works on a variety of hardware platforms is this one. That is a result of the lack of specialist hardware. When a process voluntarily enters the wait state or terminates, non-pre-emptive Scheduling takes place. As soon as processors are allocated to a process, they hold onto it until it is terminated or moves into the waiting state. The processor must finish the process it has started before moving on to the next one; the process cannot be stopped in the midst of it.

The other process would have to wait for a very long period when a non-pre-emptive process with a large CPU burst time is active, which raises the process average waiting time in the ready queue. Under non-pre-emptive Scheduling, however, there is no overhead when moving tasks from the ready queue to the CPU. Because the execution process is not even pre-empted for a process with a higher priority, the Scheduling is rigid.

When a process ends or transitions from the running to the waiting state, non-pre-emptive Scheduling is employed. Once the resources (CPU cycles) are assigned to a process under this Scheduling, the process retains the CPU until it terminates or enters a waiting state. A process operating on a CPU is not interrupted mid-execution in the case of non-pre-emptive Scheduling. Instead, it delays allocating the CPU to another process until the current one has finished its CPU burst period. It usually happens because Non-Preemptive Scheduling does not allow for the function to pause an operation in the middle, forcing it to wait until the first operation is complete.

All things considered, it persists until the cycle completes its task, at which point it will be transmitted to the subsequent process. This is because it requires specialized equipment, such as precautionary Scheduling. The key benefit is that it never interrupts a process that is consuming CPU to get CPU; instead, it always waits for the other process to end or enter a waiting state before requesting the resource. The CPU won't get overworked in this manner. Multi-level feedback queue scheduling is the non-pre-emptive scheduling technique that we have covered in this lesson. When a service outage is expected and a preventative measure has to be taken, pre-emptive Scheduling is performed. Even if it implies that other activities will be delayed, pre-emptive schedulers let jobs execute in the order that they are planned. When a company plans tasks without knowing in advance when they must be completed, this practice is known as non-pre-emptive Scheduling..

Difference Between pre-emptive and Non-pre-emptive in Points

  1. Pre-emptive scheduling allows the CPU to process for a set period, while non-pre-emptive scheduling allows the CPU to process until it finishes or enters the waiting state.
  2. Pre-emptive scheduling allows for easy process interruption, while non-pre-emptive scheduling requires that the current cycle be completed before moving on to the next one.
  3. When a higher priority task arrives, the running process in pre-emptive scheduling is halted in the midst of it; in contrast, the running process in non-pre-emptive scheduling waits until it is finished running.
  4. Pre-emptive scheduling involves scheduling numerous operations, which adds overhead to the process. Non-pre-emptive scheduling doesn't have this problem since it doesn't have a method to handle interruptions to the process.
  5. No matter which process is presently running, pre-emptive scheduling achieves flexibility by enabling the important processes to access the CPU when they enter the ready queue. Non-pre-emptive scheduling is referred to be inflexible since the CPU-intensive operation is not interrupted even if a crucial task joins the ready queue.
  6. Pre-emptive Scheduling is more affordable to use to conduct the process, however Non-Pre-emptive Scheduling is completely free.
  7. When using pre-emptive scheduling, if a high-priority process repeatedly enters the ready queue, the low-priority process must wait for a very long time and may even become hungry. The processes with shorter burst times may have to go without resources if the CPU is given to the process with a bigger burst time under non-pre-emptive scheduling.

Conclusion

The operating system may stop any cycles or operations that are in progress while using pre-emptive scheduling. This happens often because the most important procedures are handled first. Pre-emptive scheduling is a method of balancing work and personal obligations that aims to foresee potential issues or demands. This may be advantageous since it gives you the chance to prepare ahead and frees up your time so you can concentrate on other things. The distinction between pre-emptive and non-pre-emptive scheduling is sometimes unclear. Pre-emptive multitasking, which was originally introduced in the early days of computers, is where this misconception originated.

Pre-emptive scheduling has the benefit of managing staff workloads. Pre-emptive scheduling is not better than non-pre-emptive scheduling, and vice versa. It all relies on how a scheduling strategy increases CPU usage while decreasing average process waiting time. In contrast to the non-pre-emptive, it provides an algorithm for overhead switching between the jobs that are allocated. Because of this, Pre-emptive Scheduling is more adaptable and efficient than non-Pre-emptive Scheduling. Pre-emptive scheduling allows for the option of prioritising the higher priority tasks, which results in a longer completion time. Non-pre-emptive scheduling, on the other hand, results in a shorter completion time since there is no intervention during the process.

References

  • Pre-emptive and Non-Preemptive Scheduling (tutorialspoint.com)
  • Non-Preemptive Scheduling in Operating System (OS) » PREP INSTA
  • Difference Between Preemptive and Non-Preemptive Scheduling in OS (tutorialspoint.com)


Cite this article

Use the citation below to add this article to your bibliography:


Styles:

×

MLA Style Citation


"Difference Between Preemptive and Non Preemptive Scheduling in Operating Systems." Diffzy.com, 2024. Sun. 14 Apr. 2024. <https://www.diffzy.com/article/difference-between-preemptive-and-non-preemptive-scheduling-1197>.



Edited by
Diffzy


Share this article