Scheduling Algorithms
Scheduling Algorithms
CPU scheduling is the process of deciding which process will own the
CPU to use while another process is suspended. The main function of the
CPU scheduling is to ensure that whenever the CPU remains idle, the OS
has at least selected one of the processes available in the ready-to-use
line.
In Multiprogramming, if the long-term scheduler selects multiple I / O
binding processes then most of the time, the CPU remains an idle. The
function of an effective program is to improve resource utilization.
If most operating systems change their status from performance to waiting
then there may always be a chance of failure in the system. So in order to
minimize this excess, the OS needs to schedule tasks in order to make full
use of the CPU and avoid the possibility of deadlock.
Objectives of Process Scheduling Algorithm:
● Utilization of CPU at maximum level. Keep CPU as busy as
possible.
● Allocation of CPU should be fair.
Characteristics of FCFS:
● FCFS supports non-preemptive and preemptive CPU scheduling
algorithms.
● Tasks are always executed on a First-come, First-serve concept.
Disadvantages of FCFS:
● FCFS suffers from Convoy effect.
● The average waiting time is much higher than the other algorithms.
● FCFS is very simple and easy to implement and hence not much
efficient.
Shortest job first (SJF) is a scheduling process that selects the waiting
process with the smallest execution time to execute next. This scheduling
method may or may not be preemptive. Significantly reduces the average
waiting time for other processes waiting to be executed. The full form of
SJF is Shortest Job First.
Characteristics of SJF:
● Shortest Job first has the advantage of having a minimum average
waiting time among all operating system scheduling algorithms.
● It is associated with each task as a unit of time to complete.
● It may cause starvation if shorter processes keep coming. This
problem can be solved using the concept of ageing.
Disadvantages of SJF:
● One of the demerit SJF has is starvation.
Characteristics of LJF:
Advantages of LJF:
● No other task can schedule until the longest job or process
executes completely.
● All the jobs or processes finish at the same time approximately.
Disadvantages of LJF:
● Generally, the LJF algorithm gives a very high average waiting
time and average turn-around time for a given set of processes.
● This may lead to convoy effect.
4. Priority Scheduling:
● Less complex
5. Round robin:
Shortest remaining time first is the preemptive version of the Shortest job
first which we have discussed earlier where the processor is allocated to
the job closest to completion. In SRTF the process with the smallest
amount of time remaining until completion is selected to execute.
Advantages of SRTF:
Disadvantages of SRTF:
● Like the shortest job first, it also has the potential for process
starvation.
● Long processes may be held off indefinitely if short processes are
continually added.
Advantages of LRTF:
Disadvantages of LRTF:
● This algorithm gives a very high average waiting time and average
turn-around time for a given set of processes.
● This may lead to a convoy effect.
● The criteria for HRRN is Response Ratio, and the mode is Non-
Preemptive.
● HRRN is considered as the modification of Shortest Job First to
reduce the problem of starvation.
● In comparison with SJF, during the HRRN scheduling algorithm,
the CPU is allotted to the next process which has the highest
response ratio and not to the process having less burst time.
Response Ratio = (W + S)/S
Here, W is the waiting time of the process so far and S is the Burst time of
the process.
Advantages of HRRN:
Disadvantages of HRRN:
Processes in the ready queue can be divided into different classes where
each class has its own scheduling needs. For example, a common division
is a foreground (interactive) process and a background (batch) process.
These two classes have different scheduling needs. For this kind of
situation Multilevel Queue Scheduling is used.
● Starvation problem
● It is inflexible in nature