Illustration of Completely Fair Scheduler for Task scheduling using

advertisement
Illustration of Completely Fair Scheduler for
Task scheduling using AA Tree
Prajakta Pawar1, S.S.Dhotre2, S. H. Patil3
1, 2, 3
Computer Engineering Department BVDUCOE Pune-43(India)
prajakta13pawar@gmail.com
Abstract - CPU scheduler plays an important role in
operating system. The task of operating system
scheduler is to allocate CPU resources among all
processes in a proper manner. Completely Fair
Scheduler (CFS) does allocation of CPU resources fairly
without compromising interactivity performance. Also
CFS offers user fair scheduling, group scheduling and
modular scheduler framework. This research work
discuss about CFS algorithm using new approach. This
includes implementation of AA Tree for entity
management in CFS. Entity management is required to
store all runnable tasks which ultimately locate a task
that is most entitled to run at any given instance. This
paper demonstrates results of CFS using both Red
Black Tree and AA Tree and shows a comparison of
them. According to our evaluation results CFS using
AA Tree proves to be less complex than that of red
black tree.
Keywords- Task scheduling,
Scheduler, Fairness.
Completely
Fair
I. INTRODUCTION
A software that acts as an interface between a user
and computer hardware is known as operating
system. Its key functionalities include efficient
management and utilization of available system
resources [7]. In a particular system, there can be
more than one runnable process at any instance
which is demanding for resource. Thus operating
system scheduler is required to make sure that every
process gets equal share of CPU time. The operating
system scheduler is base for multitasking OS such as
Linux. For proper handling of available resources a
scheduling algorithm is required that will guarantee a
fairness. Scheduler is responsible for giving users the
impression that many processes are executing
simultaneously. The algorithm used for scheduling is
going to decide the order of executing processes and
it will dictate the performance as well.
In last few years the Linux kernel scheduler has
shown rapid development and it introduces lots of
new technologies as well as improving schemes. This
improvement is in terms of flexibility, reliability and
performance. There is remarkable performance
improvement in the field of key component of
operating system called scheduler. The schedulers in
earlier days used minimal designs includes Linux 1.2
scheduler used round robin scheduling policy and
process management through circular queue, then the
Linux 2.2 scheduler included idea of several
scheduling classes, the Linux 2.4 scheduler
introduced O(N) scheduler. The most latest Linux
schedulers are O(1) [10] and Completely Fair
Scheduler(CFS)
focused
on
performance
improvement in terms of fairness and interactivity.
The earlier version of Linux 2.6 scheduler called
O(1) scheduler was introduced by Molnar Ingo to
replace O(N) scheduler. O(1) offers better
distribution of CPU time, interactivity along with
support for Simultaneous Multiprocessing (SMP) [9].
Then Ingo Molnar developed CFS and it is included
in Linux 2.6.23 kernel. In all three schedulers
included in 2.4, 2.6 and 2.6.23 kernels while
designing O(N), O(1) and CFS, focus was paid to
strive for scalability, fairness, interactivity and SMP
[8].
Different scheduling algorithms have different
properties and characteristics. So while choosing
scheduling algorithm at particular instance, one must
consider all the properties of different algorithms.
While doing selection the criteria may include
throughput, waiting time, execution time, turnaround
time, CPU utilization, fairness etc. Fairness can be
termed as an ability to distribute system resources
such as CPU time equally among all processes on the
basis of their priorities. Due to increase in use of chip
multiprocessors, many software applications are
designed using multiple threads taking advantage of
thread level parallelism [17]. But in multithreaded
environments the scheduler will retain its starvation
free characteristic only when there is optimal
multithreaded application. In contrast to this
situation, when there exists greedy threaded
applications they will dominate CPU resources as the
scheduler uses task fairness policy. This situation will
lead to fairness issues in running applications. To
resolve fairness problem following goals are
outlined: (1) Though there is at least one runnable
task, the CPU resource cannot be idle. (2) Avoid
greedy threaded applications from dominating CPU
resource[3], [4], [5].
Contributions:
The contributions of this paper are: (1) Study and
analysis of CFS scheduler. (2) Implementation and
analysis of AA tree for CFS. (3) Demonstration of
performance through experimental evaluation.
into one scheduler framework Linux kernel 2.6.29.
According to the results obtained from their
experiment, fairness and interactivity under micro
benchmark have remarkable differences whereas in
synthesis and real applications they have minor
differences [6].
Hongyun Tian et al have proposed new approach
called CFS on NUMA based systems. UMA is
lagging behind NUMA architecture with respect to
scalability. CFS scheduler works efficiently on
NUMA platforms because of architecture aware taskbound approach for NUMA which improves the
system performance more than 60% on an average.
III.
Organisation:
The remaining part of this paper is organized as
follows: In section 2 the analysis of different
scheduling approaches is presented. Then section 3
presents detailed description of CFS and also
includes proposed scheme for CFS. Section 4
presents illustration of problem statement and
evaluation of algorithm. At the end in section 5 the
conclusion is made.
II. EXISTING SYSTEM
Chee Siang Wong et al have proposed operating
system scheduler which is intended to allocate the
CPU resources properly to all tasks [3]. In this
system, Linux CFS scheduler allocates resources
depending on number of threads in the system. It
leads to fairness between tasks using thread
scheduling algorithm. According to this system, in
multi-threaded environment thread weights are
readjusted in same process to reduce unfair allocation
of CPU resources. They also presented two different
Linux schedulers: O(1) and CFS. In this presented
system, fairness and interactivity performance is
measured
using
fairness
and
interactivity
benchmarks.
MA Wei-feng and WANG lia-hai have presented
analysis of operating system scheduler called Linux
2.6 kernel [4]. The Linux scheduler was unable to
meet customer’s need due to growth in applications
and some of them were heavy applications. They
have presented new Linux 2.6 Kernel Scheduler
which has great system performance when tested
against heavy applications.
Shen Wang et al have presented analysis of O(1),
RSDL, and CFS schedulers in systematic manner and
it also measure fairness, interactivity and multiprocessor’s performance. All schedulers are ported
COMPLETELY FAIR
ALGORITHM
3.1 Basic algorithm of CFS
According to author Ingo Molnar, the design of CFS
can be wrapped in one statement: “CFS models
‘ideal, precise, multitasking CPU ’on real hardware”.
In reality ideal CPU is non Existent because at
particular time only one task can be assigned to a
CPU time. Due to this currently executing task
receive 100 % of CPU power and all remaining tasks
get 0 % of CPU power which is not fair. To solve this
issue, CFS needs to have mechanism to calculate fair
CPU share per task and also a mechanism to keep
track of the time for which particular process was
waiting. The process with large waiting time is the
one having gravest need of CPU. Scheduler finds out
such process and it is assigned to CPU. This means
that after some time there will be some other task
with larger waiting time and currently running task is
preempted at this time. By using this principle CFS
always tries to be fair to all tasks where each process
will get equal share of CPU [18].
In CFS following components of O(1) scheduler are
removed: active and expired arrays, interactive
process identification and priority based time slices.
Improvements in CFS are: group scheduling, user fair
scheduling and modular scheduler framework. The
advantages of CFS are: good interactive performance,
maximized overall CPU utilization, fairness in every
task. In proportional share algorithm of CFS [1],[2],
140 priority levels are maintained and each task is
assigned with a weight. Weight of a schedulable
entity is decided by priority. Through the proper
assignment of weights CFS proves its fairness.
The share is calculated as:
share =
weight of schedulabe entity
total weight of all entities under CFS runqueue
(1)
𝑡𝑖𝑚𝑒 𝑠𝑙𝑖𝑐𝑒 = 𝑠ℎ𝑎𝑟𝑒 × 𝑝𝑒𝑟𝑖𝑜𝑑
(2)
Where, period is time slice the scheduler tries to
execute all tasks.
Virtual runtime is nothing but weighted time slice
given to each schedulable entity [12] and it is denotes
by using following expression:
virtual runtime+=
amount of execution time of task
weight of schedulable entity
unity value of weight
×
(3)
Basic CFS algorithm uses red black tree for entity
management. By using key value, all runnable tasks
are sorted in red black tree and it is used to calculate
minimum value of virtual runtime of all tasks which
ultimately denotes the task that has received least
amount of time slice [3], [4].
3.2 Proposed scheme of CFS using AA Tree
The proposed approach uses the CFS for scheduling
and it includes all the features of existing CFS
algorithm along with some supplementary data
structure implementation. This new scheme uses AA
Tree for entity management in CFS.Following system
flow diagram depicts the proposed system work flow.
black trees, the red nodes on an AA tree can be added
only as a right sub child. Thus, no red node can be a
left sub-child, which results in the imitation of a 2-3
tree instead of a 2-3-4 tree. It helps to simplify the
maintenance operations. And for a red-black tree [11,
13] this maintenance algorithms need to consider
seven different shapes to properly balance the tree,
while AA tree on contrast only desires to consider
two shapes due to the strict condition that only right
links can be red [14],[15].
The red-Black tree has high complexity as compared
to AA tree data structure which helped for
modification in the CFS approach used by
implementing AA tree instead of Red-Black Tree. In
AA Tree instead of color the level of a node is used
as balancing information. Red nodes are simply
nodes that located at the same level as their parents.
The level of a node in an AA-tree is: (1) Leaf nodes
are at level 1. (2) Red nodes are at the level of their
parent. (3) Black nodes are at one less than the level
of their parent. Fig 2 shows the example of AA Tree.
The AA tree fulfills following properties of RedBlack trees along with one addition to it: (1) The
color of each node is either red or black. (2)The root
is black. (3) If a color of node is red then its children
have to be black. (4) All paths from any node to a
descendent leaf must contain the same number of
black nodes. (5)Left children may not be red [16].
Fig 1: Workflow of proposed system
The implementation process and number of rotation
cases in red black tree is complex as compared to AA
tree. AA trees are named after its inventor Arne
Andersson and it is an optimization over original
binary B-trees. AA-trees has fewer rotation cases so
it is easier to code, particularly deletions eliminates
about half of the rotation cases. Contrasting to red-
Fig 2: Example of AA Tree
Thus an AA tree helps to simplify the algorithms by
removing half the restructuring cases and simplifies
deletion by eliminating an annoying case: (1)
whenever it has only one child at internal node then
that child must be a red right child (2)one can always
replace a node with the smallest child in the right sub
tree.
IV.
EVALUATION AND ANALYSIS
In order to demonstrate the problem of complexity of
RB Tree in entity management and to evaluate the
effectiveness of CFS using AA Tree, we need to do
performance experience. Initially some sample
processes were created. Those processes are then
assigned with process id,execution time, priority etc.
For implementation of algorithm a CPU share, time
slice and virtual runtime is calculated. Finally the
execution report is generated to display the results
with the help of graph. Following graph in fig 3
shows the task scheduling using CFS.
Fig 4: Graph showing results of AA Tee and RB
Tree
Fig 3: Task schduling using CFS
The experimental results shows that the entity
management for CFS using AA Tree is not as
complex as that of using Red Black Tree. During
entity management several maintenance operations
such as element search, insertion, deletion, updation
are performed. This is required to track runnable
process. The graphs in fig 4 and fig 5 displays the
results of maintenance operation using AA Tree as
well as Red Black Tree and comparison is made
among the two approaches.
Fig 5: Task graph showing combined result of AA
Tee and RB Tree.
V.
CONCLUSION :
The paper first highlighted the algorithm for
CFS Scheduler. Evaluation and analysis of
simulation results have illustrated the problem
statement. The results show that the CFS do
achieve its design goal and has advantage of
being fairer among all tasks using Red Black
Tree as well as AA Tree. In addition to this, we
proposed solution to overcome complexity of
Red Black Tree by implementing AA Tree,
involved in entity management of CFS. The test
results show that using AA Tree is less complex
than that of Red Black Tree.
REFERENCES
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
[13]
[14]
[15]
[16]
[17]
[18]
I. Stoica et. al., “A Proportional Share Resource Allocation
Algorithm for Real-time and Time-shared Systems,” in Proc.
17th IEEE Real-Time Systems Symp., Dec.1996.
Steve Goddard Jian Tang, “EEVDF Proportional Share
Resource Allocation Revisited”.
Chee Siang Wong, Ian Tan, Rosalind Deena Kumari, Fun
Wey “Towards Achieving Fairness in the Linux Scheduler”.
C.S. Wong, I.K.T. Tan, R.D. Kumari, J.W. Lam W. Fun,
“Fairness and Interactive Performance of O(1) and CFS
Linux Kernel Schedulers”, IEEE 2008.
MA Wei-feng, Wang lia-hai, “Analysis of the Linux 2.6
kernel scheduler”, International Conference on Computer
Design and Applications (ICCDA 2010).
Shen Wang, Yu Chen Wei Jiang Peng Li Ting Dai Yan Cui,
“Fairness and Interactivity of Three CPU Schedulers in
Linux”, 15th IEEE International Conference on Embedded
and Real-Time Computing Systems and Applications 2009.
A. Silberschatz, P.B. Gailvin, G. Gagne, “Operating System
Concepts,” 7th Edition, John Wiley & Sons Inc., 2005.
Understanding the Linux 2.6.8.1 CPU Scheduler By Josh
Aas 2005 Silicon Graphics, Inc. (SGI) 17th February 2005.
Jones, T.: Inside the Linux 2.6 Completely Fair Scheduler_
Copyright IBM Corporation (2009).
Molnar, I. 2007, Modular Scheduler Core and Completely
Fair Scheduler [CFS], http://lwn.net/Articles/230501/
http://www.linuxjournal.com/magazine/completely-fairscheduler
The Linux Kernel Archives Website: www.kernel.org
http://en.wikipedia.org/wiki/Red%E2%80%93black_tree.
http://en.wikipedia.org/wiki/AA_tree
http://www.cepis.org/upgrade/files/full-2004-V.pdf
http://web.eecs.umich.edu/~sugih/courses/eecs281/f11/lectur
es/12-AAtrees+Treaps.pdf
Sergey zhuravlev, “Survey of Scheduling Techniques for
Addressing Shared Resources in Multicore Processors”,
ACM Computing Surveys, Vol. V, No. N, September 2011,
Pages 1–31.
https://www.linuxfoundation.jp/jp.../seminar20080709/lfjp20
08.pdf
Download