0% found this document useful (0 votes)
67 views5 pages

Analysis and Comparison of CPU Scheduling Algorithms

badfb

Uploaded by

LoveBabbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views5 pages

Analysis and Comparison of CPU Scheduling Algorithms

badfb

Uploaded by

LoveBabbar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

International Journal of Emerging Technology and Advanced Engineering

Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 4, Issue 1, January 2014)

Analysis and Comparison of CPU Scheduling Algorithms


Pushpraj Singh1, Vinod Singh2, Anjani Pandey3
1,2,3
Assistant Professor, VITS Engineering College Satna (MP), India
Abstract Scheduling is a fundamental operating system Thus, this scheduler dictates what processes are to run
function, since almost all computer resources are scheduled on a system, and the degree of concurrency to be supported
before use. The CPU is one of the primary computer at any one time - i.e.: whether a high or low amount of
resources. Central Processing Unit (CPU) scheduling plays an processes are to be executed concurrently, and how the
important role by switching the CPU among various
split between input output intensive and CPU intensive
processes. A processor is the important resource in computer;
the operating system can make the computer more processes is to be handled. So long term scheduler is
productive. The purpose of the operating system is that to responsible for controlling the degree of
allow the process as many as possible running at all the time multiprogramming. In modern operating systems, this is
in order to make best use of CPU. The high efficient CPU used to make sure that real time processes get enough CPU
scheduler depends on design of the high quality scheduling time to finish their tasks. Without proper real time
algorithms which suits the scheduling goals. In this paper, we scheduling, modern GUIs would seem sluggish. The long
reviewed various fundamental CPU scheduling algorithms for term queue exists in the Hard Disk or the "Virtual
a single CPU and shows which algorithm is best for the Memory"
particular situation.
B) Medium-term scheduler
Keywords burst time, CPU scheduling, operating system,
Scheduling Algorithm, turnaround time, waiting time.
The medium-term scheduler (also known as mid-term
scheduler) may decide to swap out a process which has not
been active for some time, or a process which has a low
I. INTRODUCTION
priority, or a process which is taking up a large amount of
Scheduling is a fundamental operating-system function. memory in order to free up main memory for other
Almost all computer resources are scheduled before use. processes, swapping the process back in later when more
The CPU is one of the primary computer resources. Thus, memory is available, or when the process has been
its scheduling is central of operating system design. Thus unblocked and is no longer waiting for a resource.
its scheduling algorithm is heart of the OS design. When [Stallings, 396] [Stallings, 370]
more than one process is runable, the OS must decide
which one is to run first. That part of the OS concerned C) Short-term scheduler
with this decision is called scheduler and the algorithm it The short-term scheduler (also known as CPU
uses is called scheduling algorithm. A CPU scheduler is the scheduler) selects from among the pool of process resident
part of an operating system and responsible for arbitrating in memory that are ready to execute, and allocates the CPU
access to the CPU [6]. A scheduler is an OS module that to one of them. Thus the short-term scheduler makes
selects the next job to be admitted into the system and the scheduling decisions much more frequent than the long-
next process to run. term or mid-term schedulers. This scheduler can be
An operating system has three types of schedulers- long preemptive, implying that it is capable of forcibly removing
term scheduler (also known as Job scheduler), medium- processes from a CPU when it decides to allocate that CPU
term scheduler and short-term scheduler (also known as to another process, or non pre-emptive (also known as
dispatcher and CPU scheduler). "voluntary" or "co-operative"), in that case the scheduler is
unable to force processes off the CPU [6].
A) Long-term scheduler
The long-term scheduler (also known as admission
scheduler) decides which jobs or processes are to be
admitted to the ready queue (in the Main Memory); that is,
when an attempt is made to execute a program, its
admission to the set of currently executing processes is
either authorized or delayed by the long-term scheduler.

91
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 4, Issue 1, January 2014)
Turnaround time, waiting time and response time is
high.
One Process with longest burst time can monopolize
CPU, even if other process burst time is too short.
Hence, throughput is low [3].
b. Shortest Job First
The process is allocated to the CPU which has least burst
time. A scheduler arranges the processes with the least
burst time in head of the queue and longest burst time in
tail of the queue. This requires advanced knowledge or
estimations about the time required for a process to
Figure I: Process of Schedulers complete [2]. This algorithm is designed for maximum
throughput in most scenarios.
Figure I, Shows the following states have been executed
in the CPU Scheduler. Characteristics
1. When a process switches from the running state to The real difficulty with the SJF algorithm is, to know
the waiting state. the length of the next CPU request.
2. When a process switches from the running state to Starvation is possible, especially in a busy system
the ready state. with many small processes being run.
3. When a process switches from the waiting state to SJF minimizes the average waiting time [3] because it
the ready state. services small processes before it services large ones.
4. When a process terminates. While it minimizes average wait time, it may penalize
The success of a CPU scheduler depends on the design processes with high service time requests. If the ready
of high quality scheduling algorithm. High-quality CPU list is saturated, then processes with large service
scheduling algorithms rely mainly on criteria such as CPU times tend to be left in the ready list while small
utilization rate, throughput, turnaround time, waiting time processes receive service. In extreme case, when the
and response time. Thus, the main impetus of this work is system has little idle time, processes with large
to develop a generalized optimum high quality scheduling service time will never be served. This total starvation
algorithm suited for all types of job. of large processes is a serious liability of this
algorithm.
II. SCHEDULING ALGORITHMS c. Round Robin
A. Algorithms and Its Characteristics The Round Robin (RR) scheduling algorithm assigns a
The fundamental scheduling algorithms and its small unit of time, called time slice or quantum. The ready
characteristics are described in this section. processes are kept in a queue. The scheduler goes around
this queue, allocating the CPU to each process for a time
a. First Come First Serve interval of assigned quantum. New processes are added to
The most intuitive and simplest technique is to allow the the tail of the queue [4].
first process submitted to run first. This approach is called
Characteristics
as first-come, first-served (FCFS) scheduling. In effect,
processes are inserted into the tail of a queue when they are Setting the quantum too short causes too many
submitted [2]. The next process is taken from the head of context switches and lower the CPU efficiency.
the queue when each finishes running. Setting the quantum too long may cause poor
response time and approximates FCFS.
Characteristics Because of high waiting times, deadlines are rarely
Since context switches only occur upon process met in a pure RR system.
termination, and no reorganization of the process RR scheduling involves extensive overhead,
queue is required, scheduling overhead is minimal. especially with a small time unit.
The lack of prioritization does permit every process to
eventually complete, hence no starvation.
92
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 4, Issue 1, January 2014)
d. Priority Scheduling d. Priority Scheduling
The OS assigns a fixed priority rank to every process, Priority is assigned for each process as follows:
and the scheduler arranges the processes in the ready queue TABLE II
in order of their priority. Lower priority processes get PROCESS WITH ITS ID, BURST TIME AND PRIORITY
interrupted by incoming higher priority processes.
Process ID Burst Time (ms) Priority
Characteristics
P1 10 3
Starvation can happen to the low priority process.
P2 2 1
The waiting time gradually increases for the equal
priority processes [5]. P3 8 4
Higher priority processes have smaller waiting time P4 6 2
and response time.
Overhead is not minimal, nor is it significant. P2 P4 P1 P3
B. Computation of Gantt chart, Waiting Time and 0 2 8 18 26
Turnaround Time Figure V: Gantt chart for PS
Consider the following set of processes, with the length
of the CPU-burst time in milliseconds is shown in Table I. For example, turnaround time for the process is
calculated as time of submission of a process to the time of
TABLE I completion of the process is obtained through Gantt chart
PROCESS WITH ITS ID AND BURST TIME
for SJF scheduling. Turnaround time for process P1, P2, P3
Process ID Burst Time (ms) and P4 is observed as 26, 2, 16 & 8 and average turnaround
P1 10 time is (26+2+16+8)/4=13 ms.
The waiting time for the process is calculated as time
P2 2 taken by the process to wait in the ready queue is observed
P3 8 from Gantt chart for SJF scheduling. Waiting time for
P4 6 process P1, P2, P3 and P4 is obtained as 16, 0, 8 & 2
respectively and average waiting time is (16+0+8+2)/4 =
a. First Come First Serve 6.5 ms.
Similarly the turnaround time and waiting time is
P1 P2 P3 P4
calculated for all other algorithms and summarized in Table
0 10 12 20 26 III and Table IV.
Figure II: Gantt chart for FCFS From the above discussion it is clear that First Come
First Serve (FCFS) & Shortest Job First (SJF) is generally
b. Shortest Job First suitable for batch operating systems and Round Robin (RR)
P2 P4 P3 P1 & Priority Scheduling (PS) is suitable for time sharing
systems. SJF algorithm is optimum for all type of
0 2 8 16 26
scheduling algorithm. Hence, it is an algorithm with an
Figure III: Gantt chart for SJF optimum criteria and suitable for all scenarios.
c. Round Robin
Assign time quantum as 5 ms for each process
P1 P1 P1 P1 P1 P1 P1
0 5 7 12 17 22 25 26
Figure IV: Gantt chart for RR

93
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 4, Issue 1, January 2014)
TABLE III i. Waiting Time
WAITING TIME FOR INDIVIDUAL PROCESS AND AVERAGE WAITING TIME
FOR EACH SCHEDULING

WAITING TIME (ms)

Process ID
Round Priority
FCFS SJF
Robin Scheduling

P1 0 16 12 8

P2 10 0 5 0

P3 12 8 17 18
Figure VI: Comparison of Fundamental scheduling Algorithm-
Waiting Time
P4 20 2 20 2
ii. Turnaround Time
Avg
10.5 6.5 13.5 7
Waiting Time

TABLE IV
TURNAROUND TIME FOR INDIVIDUAL PROCESS AND AVERAGE
TURNAROUND TIME FOR EACH SCHEDULING

TURNAROUND TIME (ms)

Process ID
Round Priority
FCFS SJF
Robin Scheduling

P1 10 26 22 18

Figure VII: Comparison of Fundamental scheduling Algorithm-


P2 12 2 7 2 Turnaround Time

It is clearly observed that turnaround time, waiting time


P3 20 16 25 26 and response time of the processes are optimum for SJF
scheduling algorithm compared to all other fundamental
algorithms from Figure II, Figure. III, Fig. IV, Fig. V,
P4 26 8 26 8
(Figure II to Figure V are Gantt Chart) Figure VI and
Avg Figure VII. It can also be observed that throughput and
Turnaround 17 13 20 13.5 CPU utilization rate are optimum.
Time From above analysis and discussion, we can say that the
FCFS is simple to understand and suitable only for batch
III. RESULTS AND DISCUSSION system where waiting time is large. SJF scheduling
The fundamental scheduling algorithm has been algorithm gives minimum average waiting time and
simulated and justified with C++ code. Comparison of average turnaround time. The priority scheduling algorithm
the fundamental algorithm is shown in Figure VI and is based on the priority in which the highest priority job can
Figure VII. run first and the lowest priority job need to wait though it
will create a problem of starvation.

94
International Journal of Emerging Technology and Advanced Engineering
Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 4, Issue 1, January 2014)
The round robin scheduling algorithm is preemptive REFERENCES
which is based on round robin policy one of the scheduling [1] Sukanya Suranauwarat, A CPU Scheduling Algorithm Simulator,
algorithm which follows the interactive system and the October 10-13, 2007, Milwaukee, WI 37th ASEE/IEEE Frontiers in
round robin scheduling algorithm is deal with the time Education Conference.. .
sharing system. [2] Abraham Silberschatz, Peter Baer Galvin, Greg Gangne; Operating
System Concepts, edition-6, 2002, John Wiley and Sons, INC.
[3] Mr. Umar Saleem and Dr. Muhammad Younus Javed, Simulation
IV. CONCLUSIONS of CPU Scheduling Algorithm, 0-7803-6355-8/00/ $10.00 @ 2000
The SJF scheduling algorithm is to serve all types of job IEEE.
with optimum scheduling criteria. The treatment of shortest [4] Sun Huajin, Gao Deyuan, Zhang Shengbing, Wang Danghui;
Design Fast Round Robin Scheduler in FPGA, 0-7803-7547-
process in SJF scheduling tends to result in increased 5/021/$17.00 @ 2002 IEEE.
waiting time for long processes. And the long process will [5] Md. Mamunur Rashid and Md. Nasim Adhtar; A New Multilevel
never get served, though it produces minimum average CPU Scheduling Algorithm, Journals of Applied Sciences 6 (9):
waiting time and average turnaround time. 2036-2039, 2009.
The shortest job first scheduling algorithm deals with [6] Mr. Sindhu M, Mr. Rajkamal R and Mr. Vigneshwaran P, An
different approach, in this algorithm the major benefit is it Optimum Multilevel CPU Scheduling Algorithm. 978-0-7695-
4058-0/10 $26.00 2010 IEEE
gives the minimum average waiting time. It is
[7] Black, D.L., 1985. Scheduling support for concurrency and
recommended that any kind of simulation for any CPU parallelism in the mach operating system. Computer, 23:123-126.
scheduling algorithm has limited accuracy. The only way to [8] Ankur Bhardwas, Rachhpal Singh, Gaurav, Comparative Study of
evaluate a scheduling algorithm to code it and has to put it Scheduling Algorithm in Operating System International Journal of
in the operating system, only then a proper working Computer and Distributed Systems, Vol. No. 3, Issue I, April-May
capability of the algorithm can be measured in real time 2013.
systems.

95

You might also like