Historyoflinuxtutorial 4 2016
Historyoflinuxtutorial 4 2016
Assignment version
CFS
● Time-ordered red-black tree “timeline” of future task execution
● Runnable tasks are sorted using “vruntime”
● At each scheduling invocation:
○ the vruntime of the current task is incremented (time it spent using the CPU)
○ the scheduler chooses the leftmost leaf in the tree (i.e the task with the smallest vruntime)
● Leftmost node is cached (O(1)),
reinsertion of a preempted task takes O(logn)
CFS scheduling classes
Modular design in order to easily support different scheduling policies
● Use the guidelines from previous assignment in order to compile Linux kernel
and run your kernel image
How to test
● Create simple programs that initialy set their total_computation_time
○ total_computational time should be different for each
○ (10 - 20 seconds difference should be good)
● Then, each will spin for some time (don’t use sleep, a large while maybe...),
the spin should be the same for each program
● After spinning, each program should print a unique identifier
● What is the expected behaviour??
Guidelines 1/2
● Familiarize with http://lxr.free-electrons.com/source/?v=2.6.38
○ You can find function implementation, struct definition, etc… within clicks
● Another way to map source code is by using ctags
○ http://www.tutorialspoint.com/unix_commands/ctags.htm
● Use printk function, its syntax is quite the same as printf and it’s an easy way
to observe the kernel behaviour from user level (with dmesg command)
● Kernel data structures implementation is quite different from what you have
learned till now
○ https://isis.poly.edu/kulesh/stuff/src/klist/ ,lists examples
○ Search for examples for other data structures also
○ Also check the APIs for each data structure in include/linux folder
Guidelines 2/2
● Understand how the scheduler works
○ start with printing things inside schedule function
● Follow the function call path from schedule in order to find out how the next
task is picked
○ Also printing
● Reuse existing code snippets within the kernel source in order to do what you
want
○ e.g. reuse code snippets for accessing members in struct nodes, traversing data structures...
● Compile often with small changes in the source from the previous compilation
○ Massively helps with debugging
● Submit anything you can to show your effort!