As the name suggests, process Schedulers in the operating system are used to schedule the processes in the active state. It selects another process based on different strategies. Schedulers are used to promote efficient resource utilization and management of task resources.Â
In this article, we are about to know more about process schedulers in operating systems and their role in promoting effective resource utilization.
What are Process Schedulers?
Process schedulers in operating system are programs used for allocating processes for execution inside the CPU. Its main role is to ensure that the CPU does not get idle time during execution. The different stages of process schedulers are ready, waiting, and running.Â
There are many different types of process schedulers that are used to decide which process to run inside the CPU. Process schedulers ensure the minimum response time of a running program.Â
Process Schedulers In Operating System Key Takeaways
- The main role of process schedulers in operating systems is to ensure proper response time and utilization.Â
- It also maximizes the number of processes within a desired response time for the CPU.
- It ensures that CPUs do not get any ideal time and promotes effective utilization of CPU.
- These process schedulers in operating system implement priorities for the processes and avoids infinite allocation.
Types of Process Schedulers in Operating Systems
Â
There are three major types of process schedulers in an operating system. Let us get an overview of each one of them below.
- Long Term Process Scheduler
- Short Term Process Scheduler
- Medium Term Process Scheduler
1. Long Term Process SchedulerÂ
The main role of Long term process schedulers in operating systems is to control the degree of multiprogramming inside an operating system. It does so by deciding which process to admit inside the system for processing. It can select processes from secondary storage and then download them into main memory.Â
Features of Long Term SchedulersÂ
- Long-term schedulers decide and control how many processes enter the system for execution.
- It decides which jobs are to be loaded inside the system memory from the disk.
- It works at a low pace and runs when a job enters the CPU or ready state.
- It generally takes into account long term processes i,e. User jobs or batch processes.
- It affects the degree of multiprogramming inside the CPU and manages processes between secondary storage and main memory.
- It helps in balancing the CPU Bound and I/O bound processes and helps in optimizing system performance.
2. Short Term Process SchedulersÂ
Short Term Schedulers decide which process gets to use the CPU next and run very frequently inside the CPU. The main objective of short term schedulers is to make sure that the CPU is constantly utilized with a better response time. It is also popular as a CPU scheduler and plays a very important role in optimizing system performance based on certain criteria.
Features of Short Term SchedulersÂ
- It is used to allocate processes in the ready queue.
- It also selects the main process for execution using scheduling algorithms such as FCFS, Round Robin, SJF, and more.
- It runs very frequently every few milliseconds and must be very fast. It affects system responsiveness.Â
- Short term schedulers affect CPU utilization and system responsiveness.
- It manages the process between the ready queue and the CPU.
- It ensures effective CPU Utilisation and quickly switches between processes.Â
- It uses different scheduling algorithms to optimize CPU performance.
3. Medium Term Schedulers
Medium term process schedulers in operating system are an important part of swapping and enable you to handle the swapped-out processes. In this method of scheduling a running process becomes suspended, which makes an I/O request. A suspended process does not make any progress around completion. It is used to make space for other processes and ensure that the other suspended processes are removed from the storage.
Features of Medium Term SchedulersÂ
- Medium term process schedulers in operating system suspend processes that are not actively in the execution stage and then later resume them.
- Medium schedulers are used to swap out and swap in processes inside the CPU.Â
- It runs occasionally when memory management needs it and also decides which process to move to disk when memory gets full.
- It works at a moderate speed which is faster than long-term schedulers but slower than Short term schedulers.Â
- It only works with blocked or waiting processes inside the CPU i,e. Suspended processes.Â
What is the Role of Context Switching in Process Scheduling?
Context switching is the process of saving the state of a currently executing process and loading the state of another process so that execution can resume from where it was left off. This allows a CPU to switch between multiple processes efficiently, enabling multitasking and ensuring fair CPU usage. Context switching is a very important part of process schedulers in operating system.
- Context switching allows multiple tasks in a time sharing system which allows users to run multiple applications at a time.
- It is used in preemptive scheduling and ensures fair allocations of processes with the help of priority scheduling.
- It ensures fair CPU allocation and ensures that no single process monopolizes the CPU.Â
- We can handle interrupts and system calls using context switching. It allows another process to utilize the CPU until the I/O operation of the running process is completed.
- In multiprogramming, context switching allows multiple processes to reside in memory and execute in turns, improving system utilization.
What are Process Scheduling Queues In OS?
Process scheduling queues are data structures used by the operating system (OS) to manage and track the execution of processes in different stages of their lifecycle. These queues help the OS organize processes based on their status and ensure efficient CPU allocation.
There are three different types of process schedulers in operating system based on queues in the operating system namely.
- Job Queue
- Ready Queue
- Running Queue
Job Queue
It contains all the newly created processes waiting to be admitted in memory for execution. It is managed by a long-term scheduler and ensures the process stays in the queue until they are moved to the ready queue.Â
Ready Queue
Ready Queue consists of all the processes that are loaded in the main memory i,.e RAM, and waiting for execution in the CPU. It is managed and controlled by a Short term scheduler that selects one process from this queue to execute next in the process. The processes in this queue are in a ready state but not executing.Â
Running Queue
Running Queue contains the currently executing process and the process moves here from the ready queue when it gets CPU time. It is managed by a CPU scheduler and ensures that the process stays in the queue until the complete execution takes place, is interrupted, or moved to the waiting queue.
Process Scheduling Algorithms In Operating SystemÂ
Process Scheduling algorithms in Operating systems are used to determine how processes are assigned CPU time. It helps the CPU scheduler decide which process to run next from the ready queue.Â
Non Preemptive Scheduling Algorithm
In Non preemptive Scheduling algorithm when a process starts execution it cannot be interrupted until it is completed or enters a waiting state. For example: FCFS, SJF, and Priority algorithm.Â
Preemptive Scheduling Algorithm
The Operating system can interrupt a running process and assign the CPU to another process. Preemptive scheduling algorithm examples are SJF, Round Robin, Priority, and multilevel queue.Â
Popular Process Scheduler Algorithms In Operating System
Let us understand the features and highlights of some of the most popular process schedulers in operating system.
1. First Come First Served SchedulingÂ
It is a non-preemptive algorithm where processes are scheduled in order they arrive in the queue. The first process in the ready queue gets the CPU first. It is a primitive algorithm that can suffer from a high waiting time, i,e. Convoy effect.Â
- It is a non-preemptive algorithm with no context switching.
- It suffers convoy effects.
- This scheduling algorithm is used in simple batch processing.Â
2. Shortest Job First SchedulingÂ
This scheduling algorithm can either be preemptive or non-preemptive depending on the situation favored. The process having the smallest burst time gets the CPU first. In Preemptive SJF where a running process can be interrupted if any shorter process arrives in the system. It provides better CPU utilisation than FCFS.Â
- It can either be preemptive or non-preemptiveÂ
- This scheduling algorithm also suffers from starvation
- This is best for batch system execution.
3. Round Robin SchedulingÂ
Round Robin scheduling process schedulers in operating system are preemptive where each process gets a fixed time quantum and when a process is not finished, it gets to the ready queue and the next process runs in the system. This scheduling algorithm is best for fair scheduling and interactive systems.Â
- It is a preemptive algorithm with an assigned quantum for each process.
- It does not suffer from the convoy effect as other scheduling algorithms.
- It is best for time sharing systems.Â
4. Priority Scheduling Algorithm
Priority scheduling algorithms can be preemptive or non-preemptive where each process gets a priority number that ranges from lower to higher. In preemptive scheduling, higher priority are preferred first and interpret the lower priority processes.Â
- This algorithm also can be preemptive or non-preemptive.
- It suffers from the convoy effect, which can be solved with aging.
- It is best for real time systems.Â
Learn DevOps and Cloud Computing with PW Skills
Get a complete in-depth tutorials and learning programs on PW Skills through DevOps and Cloud Computing Course, completely suitable for young graduates and even professionals to upskill and build job ready skills for their portfolio.Â
Develop concepts of automation, deployment, and testing within this online program. Master tools like Jenkins, Ansible, Kubernetes, and more. Hurry! Enroll in this online learning program and get industry led live sessions and recorded lectures available within this course only at pwskills.com.
Process Schedulers in Operating System FAQs
Q1. What are process schedulers in the operating system?
Ans: Process schedulers are programs used for allocating processes for execution inside the CPU. Its main role is to ensure that the CPU does not get idle time during execution.
Q2. What are running processes in the operating system?
Ans: Running Queue contains the currently executing process and process moves here from the ready queue when it gets CPU time. It is managed by a CPU scheduler and ensures that the process stays in the queue until the complete execution takes place, interrupted or moved to the waiting queue.
Q3. What are Long process schedulers in Operating system?
Ans: The main role of Long term schedulers is to control the degree of multiprogramming inside an operating system. It does so by deciding which process to admit inside the system for processing.
Q4. What are medium term schedulers?
Ans: Medium term schedulers are an important part of swapping and enable you to handle the swapped out processes. In this method of scheduling a running process becomes suspended which makes an I/O request.