A Comparative Study of CPU Scheduling Algorithms: July 2013
A Comparative Study of CPU Scheduling Algorithms: July 2013
net/publication/249645533
CITATIONS READS
49 16,657
2 authors, including:
Neetu Goel
Vivekananda Institute Of Professional Studies
4 PUBLICATIONS 72 CITATIONS
SEE PROFILE
Some of the authors of this publication are also working on these related projects:
All content following this page was uploaded by Neetu Goel on 21 May 2015.
IJGIP
Journal homepage: www.ifrsa.org
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 245
Neetu Goel, R.B. Garg| A Comparative Study of CPU Scheduling Algorithms
the short-term scheduler makes scheduling decisions CPU when it decides to allocate that CPU to another
much more frequent than the long-term or mid-term process, or non pre-emptive (also known as "voluntary"
schedulers. This scheduler can be preemptive, implying or "co-operative"), in that case the scheduler is unable to
that it is capable of forcibly removing processes from a force processes off the CPU.
Ready Queue
Figure 1: Shows the following states have been executed in the CPU Scheduler
1. When a process switches from the running which algorithm is judged to be best. The criteria
state to the waiting state. include the following:
2. When a process switches from the running 1. Utilization/Efficiency: keep the CPU busy
state to the ready state. 100% of the time with useful work
3. When a process switches from the waiting state 2. Throughput: maximize the number of jobs
to the ready state. processed per hour.
4. When a process terminates. 3. Turnaround time: from the time of
The success of a CPU scheduler depends on the design submission to the time of completion,
of high quality scheduling algorithm. High-quality CPU minimize the time batch users must wait for
scheduling algorithms rely mainly on criteria such as output
CPU utilization rate, throughput, turnaround time, 4. Waiting time: Sum of times spent in ready
waiting time and response time. Thus, the main impetus queue - Minimize this
of this work is to develop a generalized optimum high 5. Response Time: time from submission till the
quality scheduling algorithm suited for all types of job. first response is produced, minimize response
time for interactive users
SCHEDULING CRITERIA
6. Fairness: make sure each process gets a fair
Different CPU scheduling algorithms have different share of the CPU
properties, and the choice of a particular algorithm may CPU Scheduler whenever the CPU becomes idle; the
favor one class of processes over another. In choosing operating system must select one of the processes in the
which algorithm to use in a particular situation, we must ready queue to be executed. The selection process is
consider the properties of the various algorithms. Many carried out by the short term scheduler (or CPU
criteria have been suggested for comparing CPU scheduler). The scheduler selects from among the
scheduling algorithms. Which characteristics are used processes in the memory that are ready to execute and
for comparison can make a substantial difference in allocates the CPU to one of them Figure 2 shows a
schematic of scheduling:
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 246
Neetu Goel, R.B. Garg| A Comparative Study of CPU Scheduling Algorithms
Preempted request
Scheduler
Pending request
The ready queue is not necessarily a first-in, first out case of the processor, the resource to be allocated is
(FIFO) queue. It may be implemented as a FIFO queue, execution time on the processor and the means of
priority queue, a tree or simply an unordered linked list. allocation is scheduling. This way, the scheduler is the
Conceptually, however, all the processes in the ready component of the operating system responsible to grant
queue are lined up waiting for a chance to run on the the right to CPU access to a list of several processes
CPU. (Stalling William, 2004) An operating system ready to execute. This idea is illustrated in the five state
must allocate computer resources among the potentially diagram of figure 3(Galvin et. al. 2001).
competing requirements of multiple processes. In the
New
Scheduler Dispatch
Admit
Ready Running
Interrupt
Release
I/O or Event completion
I/O or Event
wait Exit
Waiting
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 247
Neetu Goel, R.B. Garg| A Comparative Study of CPU Scheduling Algorithms
next process is taken from the head of the queue in the four state diagram of figure 4.
when each finishes running. This idea is illustrated
New
Waiting Exit
New
I/O or Event
I/O or Event completion wait Release
Waiting Exit
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 248
Neetu Goel, R.B. Garg| A Comparative Study of CPU Scheduling Algorithms
total starvation of large processes is a serious The scheduler goes around this queue, allocating
liability of this algorithm. the CPU to each process for a time interval of
c. Round Robin assigned quantum. New processes are added to the
tail of the queue [4]. This idea is illustrated in the
The Round Robin (RR) scheduling algorithm
four state diagram of figure 6.
assigns a small unit of time, called time slice or
quantum. The ready processes are kept in a queue.
Release
I/O or Event completion I/O or Event wait
Waiting Exit
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 249
Neetu Goel, R.B. Garg| A Comparative Study of CPU Scheduling Algorithms
P0 P1 P2 P3 P4 P0 P4 P0
Avg.
0 5 7 10 12 17 22 23 25
Turnaround 17.4 10.2 15.4 15.6
Time
Figure 10: Gantt chart for Round Robin
Table 3: Turnaround Time For Individual Process
d. Priority Scheduling And Average Turnaround Time For Each
Priority is assigned for each process as follows. Scheduling.
Process ID Burst Time(ms) Priority
P0 12 3
Waiting Time (ms)
P1 2 1
Process ID
P2 3 3
Priority
P3 2 4
FCFS SJF Round Scheduling
P4 6 2 Robin
Table 2: Processes with Its Id, Burst Time and
Priority P0 0 13 13 8
P1 P4 P0 P2 P3 P1 12 0 5 0
0 2 8 20 23 25 P2 14 4 7 20
Figure 11 Gantt chart for Priority Scheduling P3 17 2 10 23
For example, turnaround time for the process is P4 19 7 17 2
calculated as time of submission of a process to the time
of completion of the process is obtained through Gantt
chart for SJF scheduling. Turnaround time for process
P0, P1, P2, P3 & P4 is observed as 25,2,7,4 & 13 Avg. 12.4 5.2 10.4 10.6
respectively and average turnaround time is Waiting
(25+2+7+4+13)/5=10.2 ms. Time
The waiting time for the process is calculated as time Table 4: Waiting Time For Individual Process And
taken by the process to wait in the ready queue is Average Waiting Time For Each Scheduling
observed from Gantt chart for SJF scheduling. Waiting
time for process P0, P1, P2, P3 & P4 is obtained as 13, From the above discussion it is clear that First Come
0, 4, 2 & 7 respectively and average waiting time is First Serve (FCFS) & Shortest Job First (SJF) is
(13+0+4+2+7)/5=5.2ms. Similarly the turnaround time generally suitable for batch operating systems and
and waiting time is calculated for all other algorithms Round Robin (RR) & Priority Scheduling (PS) is
and summarized in Table 3 and Table 4. suitable for time sharing systems. No algorithm is
optimum for all type of jobs. Hence it is necessary to
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 250
Neetu Goel, R.B. Garg| A Comparative Study of CPU Scheduling Algorithms
develop an algorithm with an optimum criteria and [3] Umar Saleem and Muhammad Younus Javed,
suitable for all scenarios. “Simulation of CPU Scheduling Alogrithm”, 0-
7803-6355-8/00/$10.00@2000 IEEE
CONCLUSION & FUTURE WORK
[4] Sun Huajin’, Gao Deyuan, Zhang Shengbing,
The treatment of shortest process in SJF scheduling Wang Danghui; “ Design fast Round Robin
tends to result in increased waiting time for long Scheduler in FPGA”, 0-7803-7547-
processes. And the long process will never get served, 5/021/$17.00@2002 IEEE
though it produces minimum average waiting time and [5] Md. Mamunur Rashid and Md. Nasim Adhtar, “
average turnaround time. It is recommended that any A New Multilevel CPU Scheduling Algorithm”,
kind of simulation for any CPU scheduling algorithm Journals of Applied Sciences 6 (9): 2036-
has limited accuracy. The only way to evaluate a 2039,2009
scheduling algorithm to code it and has to put it in the [6] Sukanya Suranauwarat, “A CPU Scheduling
operating system, only then a proper working capability Algorithm Simulator”, October 10-13, 2007,
of the algorithm can be measured in real time systems. Milwaukee, WI 37th ASEE/IEEE Frontiers in
Education Conference.
REFERENCES [7] Sun Huajin’, Gao Deyuan, Zhang Shengbing,
[1] Silberschatz, A. P.B. Galvin and G. Gagne Wang Danghui;”Design Fast Round Robin
(2012), Operating System Concepts, 8th edition, Scheduler in FPGA”, 0-7803-7547-5/021/$17.00
Wiley India, @ 2002 IEEE.
[2] Sabrian, F., C.D. Nguyen, S. Jha, D. Platt and F. [8] Andrew S. Tanenbaum, Albert S. Woodhull,
Safaei, (2005). Processing resource scheduling in “Operating Systems Design and
programmable networks. Computer Implementation”, Second Edition
communication, 28:676-687 [9] Milan Milenkovic, “Operating System Concepts
and Design”, McGRAW-HILL, Computer
Science Series, Second Edition.
International Journal of Graphics & Image Processing |Vol 2|issue 4|November 2012 251