os

What do you understand by pre-emptive and non pre-emptive process ?

What do you understand by $pre-emptive and non pre-emptive process ?

os

What do you understand by $pre-emptive and non pre-emptive process ?

 

In this article, you will learn the difference between preemptive and non-preemptive scheduling. But before discussing the differences, you need to know about preemptive and non-preemptive scheduling.

What is Preemptive Scheduling?

Preemptive scheduling is a method that may be used when a process switches from a running state to a ready state or from a waiting state to a ready state. The resources are assigned to the process for a particular time and then removed. If the resources still have the remaining CPU burst time, the process is placed back in the ready queue. The process remains in the ready queue until it is given a chance to execute again.

When a high-priority process comes in the ready queue, it doesn’t have to wait for the running process to finish its burst time. However, the running process is interrupted in the middle of its execution and placed in the ready queue until the high-priority process uses the resources. As a result, each process gets some CPU time in the ready queue. It improves the overhead of switching a process from running to ready state and vice versa, increasing preemptive scheduling flexibility. It may or may not include SJF and Priority scheduling.

For example:

Let us take the example of Preemptive Scheduling. We have taken P0, P1, P2, and P3 are the four processes.

Process

Arrival Time

CPU Burst time (in millisec.)

P0

3

2

P1

2

4

P2

0

6

P3

1

4

● Firstly, the process P2 comes at time 0. So, the CPU is assigned to process P2.

● When process P2 was running, process P3 arrived at time 1, and the remaining time for process P2 (5 ms) is greater than the time needed by process P3 (4 ms). So, the processor is assigned to P3.

● When process P3 was running, process P1 came at time 2, and the remaining time for process P3 (3 ms) is less than the time needed by processes P1 (4 ms) and P2 (5 ms). As a result, P3 continues the execution.

● When process P3 continues the process, process P0 arrives at time 3. P3’s remaining time (2 ms) is equal to P0’s necessary time (2 ms). So, process P3 continues the execution.

● When process P3 finishes, the CPU is assigned to P0, which has a shorter burst time than the other processes.

● After process P0 completes, the CPU is assigned to process P1 and then to process P2.

Advantages and disadvantages of Preemptive Scheduling

There are various advantages and disadvantages of Preemptive scheduling. The advantages and disadvantages of non-preemptive scheduling are as follows:

Advantages

  1. It is a more robust method because a process may not monopolize the processor.
  2. Each event causes an interruption in the execution of ongoing tasks.
  3. It improves the average response time.
  4. It is more beneficial when you use this method in a multiprogramming environment.
  5. The operating system ensures that all running processes use the same amount of CPU.

Disadvantages

1. It requires the use of limited computational resources.

2. It takes more time suspending the executing process, switching the context, and dispatching the new incoming process.

3. If several high-priority processes arrive at the same time, the low-priority process would have to wait longer.

What is Non-Preemptive Scheduling?

Non-preemptive scheduling is a method that may be used when a process terminates or switches from a running to a waiting state. When processors are assigned to a process, they keep the process until it is eliminated or reaches a waiting state. When the processor starts the process execution, it must complete it before executing the other process, and it may not be interrupted in the middle. When a non-preemptive process with a high CPU burst time is running, the other process would have to wait for a long time, and that increases the process average waiting time in the ready queue. However, there is no overhead in transferring processes from

the ready queue to the CPU under non-preemptive scheduling. The scheduling is strict because the execution process is not even preempted for a higher priority process.

For example:

Let’s take the above preemptive scheduling example and solve it in a non-preemptive manner.

● The process P2 comes at 0, so the processor is assigned to process P2 and takes (6 ms) to execute.

● All of the processes, P0, P1, and P3, arrive in the ready queue in between. But all processes wait till process P2 finishes its CPU burst time.

● After that, the process that comes after process P2, i.e., P3, is assigned to the CPU until it finishes its burst time.

● When process P1 completes its execution, the CPU is given to process P0.

Advantages and disadvantages of Non-preemptive Scheduling

There are various advantages and disadvantages of non-preemptive scheduling. The advantages and disadvantages of non-preemptive scheduling are as follows:

Advantages

  1. It provides a low scheduling overhead.
  2. It is a very simple method.
  1. It uses less computational resources.
  2. It offers high throughput.

Disadvantages

  1. It has a poor response time for the process.
  2. A machine can freeze up due to bugs.

$ Main Differences between the Preemptive and Non-Preemptive Scheduling

Preemptive Scheduling

Non-Preemptive Scheduling

The resources are assigned to a process for a long time period.

Once resources are assigned to a process, they are held until it completes its burst period or changes to the waiting state.

Its process may be paused in the middle of the execution.

When the processor starts the process execution, it must complete it before executing the other process, and it may not be interrupted in the middle.

When a high-priority process continuously comes in the ready queue, a low-priority process can starve.

When a high burst time process uses a CPU, another process with a shorter burst time can starve.

It is flexible.

It is rigid.

It is cost associated.

It does not cost associated.

It has overheads associated with process scheduling.

It doesn’t have overhead.

It affects the design of the operating system kernel.

It doesn’t affect the design of the OS kernel.

Its CPU utilization is very high.

Its CPU utilization is very low.

Examples: Round Robin and Shortest Remaining Time First

FCFS and SJF are examples of non-preemptive scheduling.

 


 

Topics Covered :

  • what is operating system and its types
  • operating system in computer
  • operating system responsibilities
  • operating system definition
  • operating system kya hai
  • operating system in hindi
  • operating system pdf
  • operating system ppt
  • operating system full course
  • types of operating system
  • functions of operating system
  • operating system in detail
  • what is operating system full information
  • use of operating system
  • operating system
  • why operating system
  • what is operating system

 

 


 

Thanks for reading this blog. Hope you get satisfied with the blog and definitely this blog must have valued your time and effort of reading.

Take a time to connect our other digital creations such as Instagram , Facebook and Youtube.

 

🧑‍💻🧑‍💻 Social Media Links of Tech DCode :

👉🏻 YouTube : https://www.youtube.com/channel/UCjJnEdeugftBwQ3yMuD4B_A
👉🏻 Instagram : https://www.instagram.com/thetechdcode/
👉🏻 Facebook Page : https://www.facebook.com/thetechdcode
👉🏻 Twitter : https://twitter.com/thetechdcode
👉🏻 Telegram Channel : https://t.me/thetechdcode
👉🏻 Tech DCode Linktree : https://linktr.ee/thetechdcode
👉🏻 My Personal Handles : https://linktr.ee/virtualshivamin

🧑‍💻🧑‍💻 Social Media Links of SHIVAM SINGH (OWNER) :

👉🏻 Instagram : https://www.instagram.com/virtualshivamin/
👉🏻 Facebook Page : https://www.facebook.com/virtualshivamin/
👉🏻 Twitter : https://twitter.com/virtualshivamin/
👉🏻 Personal Linktree : https://linktr.ee/virtualshivamin 

 

Leave a Reply

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