Copyright

Preemptive vs. Non-Preemptive Process Scheduling

Preemptive vs. Non-Preemptive Process Scheduling
Coming up next: Deadline Scheduling for Real-Time Systems

You're on a roll. Keep up the good work!

Take Quiz Watch Next Lesson
 Replay
Your next lesson will play in 10 seconds
  • 0:04 Process Scheduling in an OS
  • 0:31 Preemptive Scheduling
  • 2:01 Non-Preemptive Scheduling
  • 2:49 Differences
  • 3:51 Scheduling Algorithms
  • 5:13 Lesson Summary
Save Save Save

Want to watch this again later?

Log in or sign up to add this lesson to a Custom Course.

Log in or Sign up

Timeline
Autoplay
Autoplay
Speed

Recommended Lessons and Courses for You

Lesson Transcript
Instructor: Ashutosh Juneja

Ashutosh has over 18 yrs of exp. in managing business & IT teams. He holds a Bachelors degree in Electronics Engineering and a Masters degree in Information Systems.

A process scheduler plays an important role in scheduling processes in an operating system. In this lesson, we'll learn about preemptive and non-preemptive scheduling and discuss the various types of scheduling algorithms used by a process scheduler.

Process Scheduling in an OS

In an operating system (OS), a process scheduler performs the important activity of scheduling a process between the ready queue and waiting queue and allocating them to the CPU. The OS assigns priority to each process and maintains these queues. The scheduler selects the process from the queue and loads it into memory for execution. There are two types of process scheduling: preemptive scheduling and non-preemptive scheduling.

Preemptive Scheduling

The scheduling in which a running process can be interrupted if a high priority process enters the queue and is allocated to the CPU is called preemptive scheduling. In this case, the current process switches from the running queue to ready queue, and the high priority process utilizes the CPU cycle.

Let's take an example where four processes, P0, P1, P2, and P3, have different arrival times in the queue. Based on their priority or burst time, these processes are interrupted and allocated the CPU.

A process P2 arrives at time 0 and allocated the CPU. Process P3 arrives at time 1, before P2 finishes execution. The time remaining for P2 is 5 milliseconds, which is larger than a time required for P3 (4 milliseconds). So CPU is allocated to process P3. Process P1 arrives at time 2. P3 continues to execute because the remaining time for P3 (3 milliseconds) is less than the time required by processes P1 (4 milliseconds) and P2 (5 milliseconds).

Process P0 arrives at time 3. Now P3 continues to run because the remaining time for P3 (2 milliseconds) is equal to the time required by P0 (2 milliseconds). After P3 finishes, the CPU is allocated to P0 as it has smaller burst time than other processes. Later, the CPU is allocated to P1 and then to P2.

Non-Preemptive Scheduling

The scheduling in which a running process cannot be interrupted by any other process is called non-preemptive scheduling. Any other process which enters the queue has to wait until the current process finishes its CPU cycle. Let's take the same example and apply non-preemptive scheduling to it.

Process P2 arrives at time 0 and is allocated the CPU until it finishes execution. While P2 is executing, processes P0, P1, P3 arrive into the ready queue. But all other processes have to wait until process P2 finishes its execution. After P2 finishes its CPU cycle, based on the arrival time, process P3 is allocated the CPU. After P3 finishes, P1 executes and then P0.

Differences

The main differences between preemptive and non-preemptive scheduling are:

To unlock this lesson you must be a Study.com Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use Study.com

Become a Study.com member and start learning now.
Become a Member  Back
What teachers are saying about Study.com
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? Study.com has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account
Support