• Skip to main content
  • Skip to primary sidebar
  • Skip to secondary sidebar
  • Skip to footer

Computer Notes

Library
    • Computer Fundamental
    • Computer Memory
    • DBMS Tutorial
    • Operating System
    • Computer Networking
    • C Programming
    • C++ Programming
    • Java Programming
    • C# Programming
    • SQL Tutorial
    • Management Tutorial
    • Computer Graphics
    • Compiler Design
    • Style Sheet
    • JavaScript Tutorial
    • Html Tutorial
    • Wordpress Tutorial
    • Python Tutorial
    • PHP Tutorial
    • JSP Tutorial
    • AngularJS Tutorial
    • Data Structures
    • E Commerce Tutorial
    • Visual Basic
    • Structs2 Tutorial
    • Digital Electronics
    • Internet Terms
    • Servlet Tutorial
    • Software Engineering
    • Interviews Questions
    • Basic Terms
    • Troubleshooting
Menu

Header Right

Home » Fundamental » OS » What is Preemptive Scheduling?
Next →
← Prev

What is Preemptive Scheduling?

By Dinesh Thakur

Definition: Preemptive Scheduling is defined as the scheduling which is done when the process changes from running state to ready state or from waiting for the state to ready state. In this, the resources are allocated to execute the process for a certain period. After this, the process is taken away in the middle and is placed in the ready queue its bursts time is left and this process will stay in ready line until it gets its turn to execute.

Suppose if a process which has the highest priority arrives, then this process does not wait for the complete execution of the current process. Instead of it, the ongoing process is interrupted in between and is placed in the ready queue until the process which has the highest priority does its execution. Thus in this way, all the processes which are in the available line get some time to run.
Example of preemptive scheduling are: Round robin scheduling, priority scheduling, and shortest job first(SJF) scheduling
Explanation
Suppose there are four processes P1, P2, P3 and P4 whose arrival time and burst time are given in the table below:

ProcessArrival TimeCPU Burst Time
P132
P224
P306
P414

Lets us understand this preemptive scheduling.

• Here, the process P3 arrives first i.e at time 0. As we know there is no process in the queue. So, the CPU is allocated to the process P3.
• When the process P3 was executing, the process P4 interrupts in-between as it arrives at time 1. Now the time left for the complete execution of the process P3 is 5 ms. This time is more than the time required by the process P4 for its implementation. So, process P4 is allocated to the CPU.
• When the process P4 was executing, the process P2 arrival time is reached. Now the time left for the execution of P4 is 3 ms. This time is less than the time required by process P2 and process P3. So, now P4 will continue.  
• When P4 is ongoing with its execution, process P1 arrives.  Now the time left for the implementation of the process P4 is 2ms. This time is equal to the time required by the process P1 which is 2ms. So, P4 will continue its execution.
• When the process P4 completes its execution, CPU will be allocated to the process P1 as its burst time is less than the other processes.
• After the completion of process P1, the process P2 will be executed, and in the end process, P3 will be executed.
Now we see how the execution takes place through GANTT chart.

We’ll be covering the following topics in this tutorial:

  • Difference between preemptive and non-preemptive scheduling
  • Advantages of Preemptive Scheduling

Difference between preemptive and non-preemptive scheduling

Preemptive SchedulingNon-Preemptive Scheduling
In preemptive scheduling, the processes are allocated for a short period.In non-preemptive scheduling, the process is allocated to the CPU, and the resource will hold the process until it completes its execution or changes its state to waiting for the state from ready state.
In this, we can interrupt the process in between of execution.In this, we can not interrupt until the process completes its execution or switches its state.
This type of schedule is flexible as each process in the ready queue gets some time to run CPU.This type of scheduling is rigid.
Preemptive scheduling has overheads of scheduling the processes.Non-preemptive scheduling has not overheads of scheduling the processes.
There is a cost associated with the preemptive scheduling.There is no cost associated with non-preemptive scheduling.
In preemptive scheduling, if a process which has high priority arrives in the ready queue, then the process which has low priority may starve.In non-preemptive scheduling, if the process which has long burst time is executing, then the other method which has less burst time may starve.

Advantages of Preemptive Scheduling

• Preemptive scheduling is more robust as one process can not utilize the CPU.
• In this, the usage of CPU is same, i.e., all, the running processes will make use of CPU equally. You can also say that preemptive scheduling is fair.
• It improves the average response time.
• Preemptive scheduling is beneficial when we use it for the multi-programming environment.
Disadvantages of preemptive scheduling
• The process which has low priority can wait for a long time if some high priority processes arrive continuously.

You’ll also like:

  1. What is Disk Scheduling? Type of Disk Scheduling
  2. Operating System Scheduling algorithms
  3. First Come First Serve(FCFS) Scheduling
  4. CPU Scheduling Algorithms
  5. What is Priority Scheduling? – Definition
Next →
← Prev
Like/Subscribe us for latest updates     

About Dinesh Thakur
Dinesh ThakurDinesh Thakur holds an B.C.A, MCDBA, MCSD certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps.

Dinesh Thakur is a Freelance Writer who helps different clients from all over the globe. Dinesh has written over 500+ blogs, 30+ eBooks, and 10000+ Posts for all types of clients.


For any type of query or something that you think is missing, please feel free to Contact us.


Primary Sidebar

Operating System

Operating System & Types

    • Operating System - Software
    • Operating System - Definition
    • Operating System - Types
    • Operating System - Functions
    • Operating System - Characteristics
    • Operating System - Services
    • Operating System - Multiprogramming
    • Operating System - Time Sharing
    • Operating System - Multiprocessor
    • Operating System - Distributed
    • Operating System - Batch Processing
    • Operating System - Real-Time
    • Operating System - Multitasking
    • Operating System - Network(NOS)
    • Operating System - Multi-User
    • Operating System - Batch
    • Operating System - External Structure
    • Operating System - MS-DOS
    • Operating System - System Software
    • Operating System - Kernel
    • Operating System - Main Functions

Operating System Scheduling

    • Operating System - Scheduling
    • Operating System - Disk Scheduling
    • Operating System - Process
    • Operating System - Round Robin
    • Operating System - CPU Scheduling
    • Operating System - (FCFS) Scheduling
    • Operating System - Preemptive
    • Operating System - Priority Scheduling

Memory

    • Operating System - Memory
    • Operating System - Cache Memory
    • Operating System - Virtual Memory
    • Operating System - Memory Partition

Operating System - What is

    • Operating System - Booting
    • Operating System - Files & Types
    • Operating System - Shell
    • Operating System - Real Time System
    • Operating System - Demand Paging
    • Operating System - Multi Tasking
    • Operating System - Parallel Processing
    • Operating System - Swapping
    • Operating System - Spooling
    • Operating System - App Software
    • Operating System - Dead Lock
    • Operating System - Batch Processing
    • Operating System - Semaphore
    • Operating System - Variable Partitioned
    • Operating System - File System
    • Operating System - Cipher Text
    • Operating System - OS/2
    • Operating System - CONFIG.SYS
    • Operating System - Segmentation
    • Operating System - CLI

Some Other Tutorials

  • OS - Application Vs System Software
  • OS - Commands in DOS
  • OS - Process States
  • OS - System Components
  • OS - Inter-Process
  • OS - Computer Languages
  • OS - System Architecture
  • OS - Directory Structure
  • OS - Process Management
  • OS - Deadlock Prevention
  • OS - Thread Vs Process
  • OS - File Sharing

Other Links

  • Operating System - PDF Version

Footer

Basic Course

  • Computer Fundamental
  • Computer Networking
  • Operating System
  • Database System
  • Computer Graphics
  • Management System
  • Software Engineering
  • Digital Electronics
  • Electronic Commerce
  • Compiler Design
  • Troubleshooting

Programming

  • Java Programming
  • Structured Query (SQL)
  • C Programming
  • C++ Programming
  • Visual Basic
  • Data Structures
  • Struts 2
  • Java Servlet
  • C# Programming
  • Basic Terms
  • Interviews

World Wide Web

  • Internet
  • Java Script
  • HTML Language
  • Cascading Style Sheet
  • Java Server Pages
  • Wordpress
  • PHP
  • Python Tutorial
  • AngularJS
  • Troubleshooting

 About Us |  Contact Us |  FAQ

Dinesh Thakur is a Technology Columinist and founder of Computer Notes.

Copyright © 2023. All Rights Reserved.