Analysis and Comparison of CPU Scheduling Algorithms
Analysis and Comparison of CPU Scheduling Algorithms
Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 4, Issue 1, January 2014)
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
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
Process ID
Round Priority
FCFS SJF
Robin Scheduling
P1 10 26 22 18
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