The CPU scheduling algorithm is an essential component of an operating system. It determines
which process is executed by the CPU at any given time. In this lecture, we will discuss the CPU
scheduling algorithm in detail.
Process Scheduling
Process scheduling is the act of assigning processes to the CPU. When a process is created, it is
added to the ready queue, which contains all the processes that are waiting to be executed. The
CPU scheduler selects a process from the ready queue and allocates the CPU to it.
CPU Scheduling Algorithms
There are several CPU scheduling algorithms, including:
1. First-Come, First-Served (FCFS) Scheduling 2. Shortest-Job-First (SJF) Scheduling
3. Priority Scheduling
4. Round Robin (RR) Scheduling
5. Multilevel Queue Scheduling
6. Multilevel Feedback Queue Scheduling
First-Come, First-Served (FCFS) Scheduling
FCFS scheduling is the simplest scheduling algorithm. In this algorithm, the process that arrives
first is executed first. The problem with this algorithm is that it may result in long waiting times
for processes with a large burst time.
Shortest-Job-First (SJF) Scheduling
SJF scheduling is based on the shortest burst time of a process. In this algorithm, the process
with the shortest burst time is executed first. The advantage of this algorithm is that it reduces the
average waiting time.
Priority Scheduling
Priority scheduling is based on the priority of a process. Each process is assigned a priority, and
the process with the highest priority is executed first. This algorithm is useful for real-time
systems where some processes are more important than others.
Round Robin (RR) Scheduling
RR scheduling is based on time slices. Each process is allocated a time slice, and the CPU
scheduler switches between processes at the end of each time slice. The advantage of this
algorithm is that it ensures that no process is blocked for a long time.