CPU Scheduling algorithms are algorithms that assign the resources of a computing system to processes. The goal of these algorithms is to maximize the usage of CPU resources while at the same time minimizing the waiting time of the processes. In this article, I will shortly go over some of the various types of CPU algorithms. As you read this article, please note that some of these algorithms perform poorly when addressing certain aspects of the overall goal, i.e.: an algorithm might maximize CPU usage but might not minimize waiting time and vice versa.
With that in mind, let's get into it.
First Come First Serve
This algorithm follows the FIFO principle. With this algorithm, whatever process comes first get to utilize the resource first. While this is a simple principle to implement, it leads to the starvation of other processes since the currently executed process must be completed before any other process is executed.
Shortest Job First
This algorithm is based on the concept that the process with the shortest time to be executed should be done first. The problem with this algorithm is that it is difficult to predict the running time of processes and if there are lots of short-running processes, long-running processes will be starved of the CPU.
Shortest Remaining Time First
This algorithm is based on the Shortest Job First algorithm with the additional benefit of pre-emptive scheduling. This simply means that longer processes can now be put on hold to execute shorter ones.
Round Robin Scheduling
This algorithm allots a fixed execution time (called a scheduling quantum) to each process. If a process completes before the time is completed, it voluntarily releases the CPU resource, otherwise, an interrupt is raised by the system and the CPU is given to the next process.
Priority Scheduling
This scheduling algorithm categorizes jobs based on priority levels. Jobs with higher priority are executed first followed by jobs with lower priority levels.
Multilevel Queue Scheduling
This algorithm partitions the queue of ready processes into various classes and each of these classes is provided with its scheduling needs.
Multilevel Feedback Queue Scheduling
This algorithm is an improvement on the Multilevel Queue Scheduling. What it does differently is that it allows processes to switch queues based on their priority level.