Published by: Zaya
Published date: 22 Jun 2021
Scheduling is the method by which a task specified by some means is assigned to resources that complete the task. Process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy. Process scheduling is an essential part of Multi-programming operating systems. Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing.
Objective and criteria of process scheduling
Preemptive scheduling is used when a process switches from running state to ready state or from waiting for state to ready state. The resources (mainly CPU cycles) are allocated to the process for a limited amount of time and then are taken away, and the process is again placed back in the ready queue if that process still has CPU burst time remaining. That process stays in the ready queue till it gets its next chance to execute.
Algorithms based on preemptive scheduling are Round Robin (RR), Shortest Job First ( SJF basically non-preemptive), and Priority (non-preemptive version), etc.
Non-preemptive Scheduling is used when a process terminates, or a process switches from running to waiting for state. In this scheduling, once the resources (CPU cycles) are allocated to a process, the process holds the CPU till it gets terminated or reaches a waiting state. In the case of non-preemptive scheduling does not interrupt a process running CPU in the middle of the execution. Instead, it waits till the process completes its CPU burst time, and then it can allocate the CPU to another process.
Algorithms based on preemptive scheduling are Shortest Remaining Time First (SRTF), Priority (preemptive version), etc.
Key Differences Between Preemptive and Non-Preemptive Scheduling:
Comparison of preemptive and Non-preemptive scheduling:
Basic | In this resources(CPU Cycle) are allocated to a process for a limited time. | Once resources(CPU Cycle) are allocated to a process, the process holds it till it completes its burst time or switches to waiting for the state. |
Interrupt | The process can be interrupted in between. | The process can not be interrupted until it terminates itself or its time is up. |
Starvation | If a process having high priority frequently arrives in the ready queue, a low priority process may starve. | If a process with a long burst time is running CPU, then later coming process with less CPU burst time may starve. |
Overhead | It has overheads of scheduling the processes. | It does not have overheads. |
Flexibility | flexible | rigid |
Cost | cost associated | no cost associated |
CPU Utilization | In preemptive scheduling, CPU utilization is high. | It is low in non-preemptive scheduling. |
Examples | Examples of preemptive scheduling are Round Robin and Shortest Remaining Time First. | Examples of non-preemptive scheduling are First Come First Serve and Shortest Job First. |