CPU scheduling is a method process or task that the CPU will run at any given moment. It is an essential part of modern operating systems as it enables multiple processes to run at the same time on the same processor. In short, the CPU scheduler decides the order and priority of the processes to run and allocates the CPU time based on various parameters such as CPU usage, throughput, turnaround, waiting time, and response time.
CPU scheduling is essential for the system’s performance and ensures that processes are executed correctly and on time. Different CPU scheduling algorithms have other properties and the choice of a particular algorithm depends on various factors. Many criteria have been suggested for comparing CPU scheduling algorithms.
Criteria of CPU Scheduling
CPU Scheduling has several criteria. Some of them are mentioned below.
The main objective of any CPU scheduling algorithm is to keep the CPU as busy as possible. Theoretically, CPU utilization can range from 0 to 100 but in a real-time system, it varies from 40 to 90 percent depending on the load upon the system.
A measure of the work done by the CPU is the number of processes being executed and completed per unit of time. This is called throughput. The throughput may vary depending on the length or duration of the processes.
For a particular process, an important criterion is how long it takes to execute that process. The time elapsed from the time of submission of a process to the time of completion is known as the turnaround time. Turn-around time is the sum of times spent waiting to get into memory, waiting in the ready queue, executing in CPU, and waiting for I/O.
Turn Around Time = Completion Time - Arrival Time.
A scheduling algorithm does not affect the time required to complete the process once it starts execution. It only affects the waiting time of a process i.e. time spent by a process waiting in the ready queue.
Waiting Time = Turnaround Time - Burst Time.
In an interactive system, turn-around time is not the best criterion. A process may produce some output fairly early and continue computing new results while previous results are being output to the user. Thus another criterion is the time taken from submission of the process of the request until the first response is produced. This measure is called response time.
Response Time = CPU Allocation Time(when the CPU was allocated for the first) - Arrival Time
The completion time is the time when the process stops executing, which means that the process has completed its burst time and is completely executed.
If the operating system assigns priorities to processes, the scheduling mechanism should favor the higher-priority processes.
A given process always should run in about the same amount of time under a similar system load.
Importance of Selecting the Right CPU Scheduling Algorithm for Specific Situations
It is important to choose the correct CPU scheduling algorithm because different algorithms have different priorities for different CPU scheduling criteria.Different algorithms have different strengths and weaknesses. Choosing the wrong CPU scheduling algorithm in a given situation can result in suboptimal performance of the system.
Here are some examples of CPU scheduling algorithms that work well in different situations.
Round Robin scheduling algorithm works well in a time-sharing system where tasks have to be completed in a short period of time.SJF scheduling algorithm works best in a batch processing system where shorter jobs have to be completed first in order to increase throughput.Priority scheduling algorithm works better in a real-time system where certain tasks have to be prioritized so that they can be completed in a timely manner.
Factors Influencing CPU Scheduling Algorithms
There are many factors that influence the choice of CPU scheduling algorithm. Some of them are listed below.
- The number of processes.
- The processing time required.
- The urgency of tasks.
- The system requirements.
Selecting the correct algorithm will ensure that the system will use system resources efficiently, increase productivity, and improve user satisfaction.
CPU Scheduling Algorithms
There are several CPU Scheduling Algorithms, that are listed below.
FAQs on CPU Scheduling Criteria
Q.1: How does CPU utilization affect scheduling algorithms?
CPU utilization indicates the efficiency of utilizing the CPU’s processing power. Scheduling algorithms aim to keep the CPU as busy as possible to achieve high utilization. However, excessively high CPU utilization can lead to poor system responsiveness and potential resource contention.
Q.2: What is throughput in the context of scheduling algorithms?
Throughput refers to the number of processes that are completed and leave the system within a given time frame. Scheduling algorithms that maximize throughput often prioritize short processes or those that require minimal CPU time, allowing more processes to be completed in a given period.
Q.3: Why is turnaround time an important criterion for scheduling algorithms?
Turnaround time measures the overall time a process takes to complete, from submission to termination. Lower turnaround time indicates efficient process execution. Scheduling algorithms that minimize turnaround time generally prioritize processes with shorter burst times or high priority.
Level Up Your GATE Prep!
Embark on a transformative journey towards GATE success by choosing Data Science & AI
as your second paper choice with our specialized course. If you find yourself lost in the vast landscape of the GATE syllabus, our program is the compass you need.