0% found this document useful (0 votes)
61 views

A Comprehensive Study of CPU Scheduling Algorithms

This document summarizes a study on CPU scheduling algorithms. It discusses the importance of CPU scheduling in multi-programming systems to maximize CPU utilization. It describes common scheduling algorithms like FCFS, SJF, priority scheduling, and round robin. The paper analyzes these algorithms based on scheduling criteria like turnaround time, response time, waiting time, and context switches. It also defines the role of the dispatcher in CPU scheduling and different types of scheduling like long-term, medium-term, and short-term scheduling. The goal is to compare scheduling algorithms and determine the best approach based on optimization of CPU usage, throughput, and other performance metrics.

Uploaded by

badg15594
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

A Comprehensive Study of CPU Scheduling Algorithms

This document summarizes a study on CPU scheduling algorithms. It discusses the importance of CPU scheduling in multi-programming systems to maximize CPU utilization. It describes common scheduling algorithms like FCFS, SJF, priority scheduling, and round robin. The paper analyzes these algorithms based on scheduling criteria like turnaround time, response time, waiting time, and context switches. It also defines the role of the dispatcher in CPU scheduling and different types of scheduling like long-term, medium-term, and short-term scheduling. The goal is to compare scheduling algorithms and determine the best approach based on optimization of CPU usage, throughput, and other performance metrics.

Uploaded by

badg15594
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

International Journal of Advances in Engineering and Management (IJAEM)

Volume 2, Issue 10, pp: 7-11 www.ijaem.net ISSN: 2395-5252

A Comprehensive Study of CPU Scheduling Algorithms


Keerth ana V, Gopika Meena S, Shri Haritha S, Dr.M. Sujithra
M.C.A, M.Phil., PhD, Dr.A.D. Chitra M.C.A, M.Phil., PhD,
2nd Year, M.Sc. Software Systems (Integrated), Coimbatore Institute of Technology, Coimbatore
Assistant Professor, Department of Data Science, Coimbatore Institute of Technology, Coimbatore
Assistant Professor, Department of Software Systems, Coimbatore Institute of Technology, Coimbatore

-------------------------------------------------------------------------------------------------------------------------------------
Date of Submission: 20-11-2020 Date of Acceptance: 03-12-2020
--------------------------------------------------------------------------------------------------------------------------------------

ABSTRACT: In the operating system, Scheduling to scale back this overhead, the OS must schedule
of CPU plays a vital role in designing. The main the roles to urge the optimal utilization of CPU and
objective of our project is to compare different to avoid the likelihood to deadlock.
types of algorithms like First Come First Served
Scheduling, Shortest Job First Scheduling, Priority I. INTRODUCTION
Scheduling, Round Robin Scheduling, which helps Nowadays the operating system is more
us to improve the CPU efficiency and Timesharing complex, they are working on multitasking,
in the operating system. This paper depicts the multiprocessing environment in which process is
study of various scheduling algorithms for a CPU executed concurrently. The need for a scheduling
with the help of the Gantt chart. algorithm arises from the requirement for most
Why CPU scheduling? modern systems to perform multitasking (execute
In the uni-programming systems, when a process more than one process at a time) and
waits for an I/O operation, the CPU remains idle. multiprocessing (transmit multiple flows
This is an overhead and it wastes the time and simultaneously). There are several scheduling
causes the problem of starvation. However, In algorithms available as FCFS (First Come First
Multiprogramming systems, the CPU doesn't Serve), SJF (Shortest Job First), Priority
remain idle during the waiting time of the Process Scheduling, and RR (Round Robin) scheduling
and it executes other processes. algorithm. There are some scheduling criteria, like
In Multiprogramming systems, the Operating turnaround time, response time, waiting time, and
system schedules the processes of the CPU to make several contexts switching based on these criteria
maximum utilization of it and this is called CPU we analyze and determine which scheduling
scheduling. The Operating System uses various algorithm is best. In this paper, we introduce basic
scheduling algorithm to schedule the processes of CPU-scheduling concepts and present several
the CPU. CPU-scheduling algorithms.
The short-term scheduler schedules the task of
CPU for the number of processes present in the Job II. ORGANIZATION OF THE PAPER
Pool. (Section iii) describes the dispatcher
Whenever the running process requests some I/O (section iv) describes the types of scheduling
operation then the short-term scheduler saves the (section v)
present context of the method called PCB and Describes the scheduling criteria (section vi)
changes its state from running to waiting. Now the describes various CPU scheduling algorithms with
process is in waiting state; the Short-term scheduler their Gantt charts (section vii) contains the
picks another process from the ready queue and conclusion (section viii) provides the references
assigns the CPU to the present process. This
procedure is named context switching. In III. CPU SCHEDULING: DISPATCHER
Multiprogramming, if the long-term scheduler has The dispatcher is one of the components
more I/O bound processes then most of the time, involved in the CPU scheduling function. The
the CPU remains idle. The task of OS is to dispatcher is a module that gives control to the
optimize the use of resources. CPU process selected by the short-term scheduler.
If most of the running processes change their state The functions are:
from running to waiting then there could also be an  Switching context
opportunity of deadlock within the system. Hence  Switching to user mode
DOI: 10.35629/5252-02100711 | Impact Factor value 7.429 | ISO 9001: 2008 Certified Journal Page 7
International Journal of Advances in Engineering and Management (IJAEM)
Volume 2, Issue 10, pp: 7-11 www.ijaem.net ISSN: 2395-5252

 Jumping to the proper location in the user time). Considering a true system, CPU usage
program to restart that program from where it should range from 40% (lightly loaded) to
left last time. 90%(heavily loaded.)
The dispatcher should be as fast as 5.2 Throughput
possible, as long as it's invoked during every It is the entire number of processes
process switch. The time taken by the dispatcher to completed per unit time or rather says the total
prevent one process and start another process is amount of labor done in a unit of your time. this
Dispatch Latency. Dispatch Latency is often might range from 10/second to 1/hour counting on
explained using the below figure: the precise processes.
5.3 Turnaround Time
It is the quantity of your time taken to
execute a particular process, i.e. The interval from
the time of submission of the method to the time of
completion of the process (Wall clock time).
5.4 Waiting Time
The sum of the periods spent waiting
within the ready queue amount of your time a
process has been waiting within the ready queue to
accumulate get control on the CPU.
5.5 Load Average
It is the typical number of processes residing in the
ready queue expecting their address get into the
CPU.
IV. TYPES OF SCHEDULING. 5.6 Response Time
4.2 Medium-Term Scheduling The amount of your time it takes from
Long-term scheduling performs like a
when an invitation was submitted until the primary
gatekeeping function. It decides whether there is response is produced. Remember, it's the time till
enough memory, to allow jobs into the system. It
the primary response and not the completion of
limits the process of multi-tasking to prevent slow
process execution (final response). In common
performance on current-running programs. When a
CPU utilization and Throughput are maximized and
job gets into the long-term scheduler, it is sent on other factors are reduced for proper optimization.
to the medium-term scheduler.

4.2 Medium-Term Scheduling


VI. SCHEDULING ALGORITHMS
To decide which process to execute first and which
process to execute last to achieve maximum CPU
The medium-term scheduler decides to
utilization, computer scientists have defined some
send a job to the sideline until a more important
algorithms, they are:
process is finalized. Later, when the computer has
less important jobs, the medium-term scheduler  First Come First Serve (FCFS) Scheduling
will allow the suspended job to pass.  Shortest-Job-First (SJF) Scheduling
 Priority Scheduling
4.3 Short-Term Scheduling  Shortest Remaining Time First (SRTF)
The short-term scheduler takes jobs from Scheduling
the "ready" line and it will execute to run with a  Round Robin (RR) Scheduling
green light. The short-term scheduler runs the  Highest Response Ratio Next (HRRN)
highest-priority jobs first and it makes on-the-spot Scheduling
decisions. For example, when a running process is  Multilevel Feedback Queue Scheduling
interrupted it may be changed, the short-term
scheduler must recalibrate and gives the green light 6.1 First Come First Serve (FCFS) Scheduling
for the highest-priority job. In the "First come first serve" scheduling
algorithm, because the name suggests, the method
V. 5.SCHEDULING CRITERIA which arrives first, gets executed first, or we will
5.1 CPU Utilization say that the method which requests the CPU first,
To make out the simplest use of CPU and gets the CPU allocated first.
to not waste any CPU cycle, CPU would be  First Come First Serve, is simply like
working most of the time(Ideally 100% of the FIFO(First in First out) Queue arrangement,

DOI: 10.35629/5252-02100711 | Impact Factor value 7.429 | ISO 9001: 2008 Certified Journal Page 8
International Journal of Advances in Engineering and Management (IJAEM)
Volume 2, Issue 10, pp: 7-11 www.ijaem.net ISSN: 2395-5252

where the info element which is added to the To successfully implement it, the burst
queue first, is that the one who leaves the time/duration time of the processes should be
queue first. known to the processor beforehand, which is
 This is employed in Batch Systems. practically not feasible all the time.This scheduling
 It's easy to know and implement algorithm is perfect if all the jobs/processes are
programmatically, employing a Queue available at an equivalent time. (either time of
arrangement, where a replacement process arrival is 0 for all, or time of arrival is the same for
enters through the tail of the queue, and all)
therefore the scheduler selects a process from
the top of the queue. 6.2.1 Non-Preemptive Shortest Job First
 Poor in performance because the average wait Consider the below processes available in the ready
time is high. queue for execution, with arrival time as 0 for all
 A perfect real-life example of FCFS and given burst times.
scheduling is buying tickets at the ticket
counter.
Consider the processes P1, P2, P3, P4 given in the
below table, arrives for execution in the same
order, with Arrival Time 0, and given Burst Time,
let's find the average waiting time using the FCFS
scheduling algorithm.

As you can see in the GANTT chart


above, the process P4 will be picked up first as it
has the shortest burst time, then P2, followed by P3
and at last P1.
We scheduled the same set of processes using the
First Come First Serve algorithm in the previous
tutorial and got the average waiting time to be
The average waiting time will be 18.75 ms 18.75 ms, whereas, with SJF, the average waiting
For the above-given processes, first P1 will be time comes out 4.5 ms.
provided with the CPU resources,
 Hence, the waiting time for P1 will be 0 6.1.2 Pre-emptive Shortest Job First
 P1 requires 21 ms for completion, hence In Preemptive Shortest Job First
waiting time for P2 will be 21 ms Scheduling, jobs are put into the ready queue as
they arrive, but as a process with short burst time
 Similarly, the waiting time for process P3 will
arrives, the existing process is preempted or
be the execution time of P1 + execution time
removed from execution, and the shorter job is
for P2, which will be (21 + 3) ms = 24 ms.
executed first.
 For process P4 it will be the sum of execution
times of P1, P2, and P3.
The GANTT chart above perfectly represents the
waiting time for each process.

6.2 Shortest-Job-First(SJF) Scheduling


Shortest Job First scheduling works on the method
with the shortest burst time or duration first.This is
the best approach to attenuate waiting time.This is
employed in Batch Systems.It is of two types:
o Non-Preemptive
o Pre-emptive
DOI: 10.35629/5252-02100711 | Impact Factor value 7.429 | ISO 9001: 2008 Certified Journal Page 9
International Journal of Advances in Engineering and Management (IJAEM)
Volume 2, Issue 10, pp: 7-11 www.ijaem.net ISSN: 2395-5252

As you can see in the GANTT chart that the


processes are given CPU time just based on the
As you can see in the GANTT chart priorities.
above, as P1 arrives first, hence its execution starts
immediately, but just after 1 ms, process P2 arrives 6.4 Shortest Remaining Time
with a burst time of 3 mswhich is less than the  Shortest remaining time (SRT) is that the
burst time of P1, hence the process P1(1 ms done, preemptive version of the SJN algorithm.
20 ms left) is preempted and process P2 is  The processor is allocated to the work closest
executed. to completion but it is often preempted by a
As P2 is getting executed, after 1 ms, P3 more ready job with a shorter time to
arrives, but it has a burst time greater than that of completion.
P2, hence the execution of P2 continues. But after  Impossible to implement in interactive systems
another millisecond, P4 arrives with a burst time of where required CPU time isn't known.
2 ms, as a result, P2(2 ms done, 1 ms left) is  It is usually utilized in batch environments
preempted and P4 is executed. where short jobs got to give preference.
After the completion of P4, process P2 is
picked up and finishes, then P2 will get executed
and at last P1.
The Pre-emptive SJF is also known as Shortest
Remaining Time First because, at any given point
of time, the job with the shortest remaining time is
executed first.

6.3 Priority Scheduling


 Priority scheduling is a non-preemptive
algorithm and one among the foremost
common scheduling algorithms in batch
systems.
 Each process is assigned a priority. The
process with the highest priority is to be
executed first then on.
 Processes with the same priority are executed
on a first-come-first-served basis.
6.5 Round Robin(RR) Scheduling
 Priority is often decided to support memory
 Round Robin is the preemptive process
requirements, time requirements, or the other
scheduling algorithm.
resource requirement.
Consider the below table for processes with their  Each process is provided a fixed time to
respective CPU burst times and the priorities. Let execute, it's called a quantum.
the arrival time be 0 for all the processes.  Once a process is executed for a given time,
it's preempted and another process executes for
a given period.

DOI: 10.35629/5252-02100711 | Impact Factor value 7.429 | ISO 9001: 2008 Certified Journal Page 10
International Journal of Advances in Engineering and Management (IJAEM)
Volume 2, Issue 10, pp: 7-11 www.ijaem.net ISSN: 2395-5252

 Context switching is employed to save lots of


states of preempted processes. 6.7 Multilevel Feedback Queue Scheduling
Consider all the process’s arrival time is 0. Multiple-level queues aren't an independent
scheduling algorithm. they create the use of other
existing algorithms to the group and schedule jobs
with common characteristics.
 Multiple queues are maintained for processes
with common characteristics.
 Each queue can have its scheduling algorithms.
 Priorities are assigned to each queue.
For example, CPU-bound jobs are often scheduled
in one queue, and each one I/O-bound jobs in
another queue. the tactic Scheduler then alternately
selects jobs from each queue and assigns them to
the CPU supported the algorithm assigned to the
Here, the time quantum=5 queue.

6.6 Highest Response Ratio Next


(HRRN)Scheduling
 Highest Response Ratio Next (HRNN) is one
of the foremost optimal scheduling algorithms.
 This is a non-preemptive algorithm during
which, the scheduling is completed on the idea
of an additional parameter called Response
Ratio.
 A Response Ratio is calculated for every one
of the available jobs and therefore the Job with VII. CONCLUSION
the very best response ratio is given priority The above mentioned are the different
over the others. CPU scheduling utilized in this day. These
 Response Ratio is calculated by the given algorithms are inherited supported by the need for
formula.Response Ratio = (W+S)/S the processor. Scheduling algorithms shouldn't
Where, affect the behavior of the system (same results no
W → Waiting Time matter schedule). However, the algorithms do
S → Service Time or Burst Time impact the system's efficiency and reaction time.

REFERENCE
[1]. William Stallings, "Operating systems
Internals and Design Principles", 4th edition,
PHI, 2001.
[2]. https://www.wikipedia.org/
[3]. Silberschatz A., Peterson J.L and Galvin P.,
"Operating System Concepts", John Wiley
Publishing Company, 2002.
[4]. H.M.Deital, " An introduction to Operating
when P1 enters, it gets executed. P2, P3, and P4 System", Pearson Education, 2001
will be waiting. After the execution of P1, the [5]. Charles Crowley, "Operating System a
process with the highest response ratio must be Design Oriented Approach", Tata McGraw
executed. Hill, 2000.
RR(P2) = (21-1)+3/3=7.666 [6]. Milankovic M, "Operating System Concepts
RR(P3) = (21-2)+6/6=4.166 & Design", McGraw Hill,1999.
RR(P4) = (21-3)+2/2=10 [7]. ArmassDanesl, "Mastering Linux", Premium
Hence, P4 will be executed next since it has the Edition, BPB Publications, 1999.
highest response ratio.
RR(P2) = (23-1)+3/3=8.333
RR(P3) = (23-2)+6/6=4.5
P2 will be executed and then P3 will be executed.

DOI: 10.35629/5252-02100711 | Impact Factor value 7.429 | ISO 9001: 2008 Certified Journal Page 11

You might also like