×

What is Scheduling on OS

Scheduling is the process which is used to share the computing resources such as memory, processor time, and bandwidth to the different processes, data flows, threads, and applications which need them. Scheduling is used to balance traffic on the system and for appropriate usage or distribution of resources and assign priorities according to the set of rules.

Through scheduling, a computer system is able to serve all requests as well as provide some quality services.     

In a system, Scheduling is carried out with the help of an aptly scheduler, which primarily deals with three things:

1. Latency: - It is the turnaround time or, in other words, latency is the time to complete the job from the time of the request to the time of submission of the job, which also consists of waiting time.

2. Response Time: - Response Time is the time required to serve the process or request.

3. Throughput: - Throughput is the time to finish the task from starting to the end per unit time.

What is CPU Scheduling in OS

CPU scheduling is defined as a method which permits the process to use the CPU conveniently. It is an efficient way when another process execution is on hold or in a waiting state because of lack of resources such as I/O, etc. The purpose of CPU scheduling is to improve the efficiency of the system and make the system fast and fair.

The operating system (OS) chooses the process for execution in the ready queue, at the time when the CPU remains ideal. The process is chosen by the use of a short-term scheduler. The task of the scheduler is to choose the processes in the memory which are to be executed and then allocates the CPU to one of the processes.

The decision of CPU scheduling takes place under the following cases.

  1. When the CPU switches a process from running to waiting state.

Example: - If a process requests for a resource and the resource is held by another process, then in this situation, the process enters from the running state to the waiting state.

  • If a process switches from running state to the ready state. Example: When an interrupt occurs between processes.
  • If a process switches from waiting to running state. Example: The completion of I/O.
  • If a process terminates.

In 1st and 4th case, there is no option for scheduling. A new process should be chosen for execution. But there is an option in case 2 and 3.

If scheduling is done under 1st and 4th case, then scheduling scheme is known as Non-Preemptive scheduling. otherwise, it is known as Preemptive Scheduling.

Types of Scheduling in OS

There are two types of Scheduling:

  1. Preemptive Scheduling
  2. Non-Preemptive Scheduling

Preemptive Scheduling

Preemptive scheduling is a type of scheduling where a process switches from running state to ready state and waiting state to ready state.  In Preemptive Scheduling, resources are allocated to the process for some time, and then it is taken back, and if that process still has CPU burst time remaining, then the process is again put back into the ready queue. The process remains in ready queue until it gets the next turn for its execution.

Preemptive scheduling is priority-based scheduling. The process having the highest priority is always processed and utilizes the resources like CPU.

Algorithm used in preemptive scheduling are Priority scheduling, Shortest Remaining Time First (SRTF), Round Robin (RR), etc.

Non-Preemptive Scheduling

Non-Preemptive Scheduling is another type of Scheduling which is used when a process terminates, or when a process changes from running state to waiting state. In Non-Preemptive Scheduling, if the resources are allocated to the process, then the process holds the CPU until the process is terminated or enters into a waiting state. In Non-Preemptive scheduling if the process is running then no interrupt is allowed in between the execution of the process. Instead, it waits until its CPU burst time is complete, and it can then assign the CPU to another operation.

Non-preemptive scheduling is the only scheduling which is used on some hardware platforms because it does not need any hardware for preemptive scheduling.  

Difference between Preemptive and Non-Preemptive Scheduling

    Preemptive Scheduling  Non-Preemptive Scheduling
In Preemptive Scheduling, CPU is allocated for a limited time In Non-Preemptive Scheduling, CPU is allocated until the process finishes its execution.
Interrupt may occur between the execution of the process. Interrupt cannot occur until the process completes its execution.  
Preemptive Scheduling is flexible Non-Preemptive Scheduling is rigid
In preemptive Scheduling, there may be a chance of overhead of scheduling process In Non-Preemptive Scheduling there is no overhead of scheduling the process.
Preemptive scheduling is related to cost. Non-Preemptive Scheduling is not related to cost.
In preemptive scheduling, when the high-priority process moves into the ready queue, the low-priority process can starve. In Non-Preemptive Scheduling, when a process having more burst time is running the CPU, then that process which have less burst time can starve. 

CPU Scheduling: Dispatcher

The Dispatcher is the element which is present in the CPU scheduling function. Dispatcher module is used in CPU scheduling, which provides control to the CPU in the selection of processes using short-term scheduler.

Dispatcher involves:

  • Context switching
  • Switching to user mode.
  • Skipping to the user program’s correct location to again start the program from where it was left.

The dispatcher must be quick as possible, as it is called at every process’s turn. The time taken by the dispatcher to stop one process and resume another one, is called as Dispatch Latency.

The following figure shows the Dispatch latency.  

CPU Scheduling: Scheduling Criteria

There are various criteria for CPU Scheduling:

  1. Throughput
  2. CPU Utilization
  3. Load Average
  4. Turnaround Time
  5. Waiting Time
  6. Response Time

Throughput: - Throughput is defined as the total number of processes completed its execution per unit time. Depending on the specific processes, this can vary from 10/second to 1/hour.

CPU Utilization: - CPU utilization is an essential task in which the operating system must ensure that the CPU stays as active as possible most of the time. for better output. It can be between from 0 to 100 percent, but in the Real-Time operating system, the range is 40 percent, for low-level, and for the high-level system it can be 90 percent. For better CPU utilization, CPU must stay busy all the time.

Load Average: - Load average is the average number of processes present in the ready queue and waiting for the CPU.

Turnaround Time: - Turnaround Time is defined as the total amount of time process consumed from its arrival to its completion. In other words, it is the total amount of time to execute a specific process.

Waiting Time: - Waiting time is the cumulative amount of time for which the process has waited for the allocation of the CPU.

Response Time: - Response Time is defined as the difference between the time of arrival and the time in which the process gets the CPU first.


Related Topics

Strategies for Handling Deadlock

Strategies for Handling Deadlock The Strategies for handling Deadlock are: Deadlock IgnoranceDeadlock PreventionDeadlock AvoidanceDeadlock Detection and Recovery Deadlock Ignorance Deadlock Ignorance is the most popular deadlock handling strategy. We can use this in the various operating systems for...

2 minutes read.

Can a Computer Run Without the Operating System

Computers may function right out of the box, mostly due to operating systems. Nowadays, there are probably already some pre-installed apps in a new computer when you buy one. Have...

9 minutes read.

Inter Process Communication in Operating System

Inter-Process Communication or IPC refers to the methods and techniques that allow processes (programs or tasks) to communicate with each other within a computer system. This is typically done through...

3 minutes read.

Contiguous Memory Allocation in Operating System

Memory is a place where data, facts, figures, and information are stored for temporary or permanent access the data in future, which is also considered as the storage place. Allocation of...

4 minutes read.

Real-time Operating System

In this essay, we will thoroughly understand the real-time operating system. Real-Time Operating System: What do you mean? For any task to be completed, a real-time operating system (RTOS), a special-purpose operating...

5 minutes read.

Distributed Shared Memory

Distributed Shared Memory is a process of managing memory over more than one node and makes inter-process communication which transfers to end users. It is a mechanism that allows user...

2 minutes read.

Kernel in OS

What is Kernel in OS? The kernel is the core component in the operating system. The job of the kernel is to handle the communication between the hardware and the software. ...

2 minutes read.

File in Operating System

What is File in Operating System?  A file is defined as a collection of the interrelated information that is stored in the secondary memory or the non-volatile memory such as optical...

4 minutes read.

Process Schedulers and Process Queue in OS

Process Schedulers There are various types of Process Schedulers: Long Term SchedulerShort Term SchedulerMedium Term Scheduler                                            Long Term Scheduler: - Long term scheduler is also referred to as Job Scheduler. The task of the Long-term...

3 minutes read.

Round-Robin Scheduling Algorithm in OS

Round-Robin is a Preemptive Scheduling Algorithm and is the most commonly used algorithm in CPU Scheduling.In this, each Process is assigned with a fix time interval to execute, which is...

5 minutes read.

Difference between C-LOOK and C-SCAN Disk Scheduling Algorithm

Disk scheduling is used by operating systems to arrange the arrival of I/O requests to the disc. I/O scheduling is another name for disc scheduling. Disk scheduling is necessary because...

4 minutes read.

Process Management in OS

A Program will not do anything unless a CPU executes its instructions. An executing program is called a process. The Process requires computer resources to complete its task. More than...

3 minutes read.

Ubuntu Operating System

Ubuntu Operating System Ubuntu is an open-source and a Linux based operating system. Ubuntu is developed for the Network Servers, Computers, and Smartphones. The Ubuntu operating system was developed by Canonical...

3 minutes read.

Linux Operating System

What is Linux? The Linux operating system is used on various devices, including cellphones, automobiles, supercomputers, household gadgets, personal computers, and business servers. You can find Linux on your phones, thermostats, vehicles,...

8 minutes read.

Difference between C-SCAN and SSTF Disk Scheduling Algorithm

C-SCAN / Circular Elevator The circular SCAN (C-SCAN) scheduling method is a modified version of the SCAN disc scheduling technique that addresses the SCAN algorithm's inefficiency by more equitably serving requests....

3 minutes read.

Process Synchronization | Operating System

Process Synchronization Process Synchronization means managing the process in such a manner so that no two processes have access to share similar data and resources. We can use Process Synchronization in a Multi-Process System...

4 minutes read.

Banker’s Algorithm in Operating System

What is Banker’s Algorithm? Bankers algorithm is an algorithm which is used for deadlock avoidance and resource allocation. It was established by Edsger Dijkstra. The reason behind the name ‘banker’s algorithm’...

8 minutes read.

Batch Operating System

Computers were once quite huge devices that operated from a console. Tape drives, punch cards, line printers were often utilized for the output, and tape drivers or card readers for...

4 minutes read.

Difference between SCAN and FCFS Disk Scheduling Algorithm

SCAN / Elevator Algorithm A different form of disc scheduling method is the SCAN disc scheduling algorithm. We move the disc arm in a certain direction in this process (the direction...

3 minutes read.

Interested Variable Mechanism

Interested Variable Mechanism It is a must to provide progress to the process synchronization mechanism. In variable mechanism, if there is a process that doesn’t need to enter into the critical section, then due...

5 minutes read.