<div dir="ltr">thanks</div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Feb 13, 2016 at 2:19 PM, Henrik Austad <span dir="ltr"><<a href="mailto:henrik@austad.us" target="_blank">henrik@austad.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sat, Feb 13, 2016 at 11:42:57AM +0530, Nitin Varyani wrote:<br>
> Hello,<br>
<br>
Hi Nitin,<br>
<span class=""><br>
> I want to understand the flow of code of process scheduler of<br>
> linux kernel. What I have understood is that<br>
> The task marks itself as sleeping,<br>
> puts itself on a wait queue,<br>
> removes itself from the red-black tree of runnable, and<br>
> calls schedule() to select a new process to execute.<br>
><br>
> for Waking back up<br>
> The task is set as runnable,<br>
> removed from the wait queue,<br>
> and added back to the red-black tree.<br>
><br>
> Can I get the details of which function does what? in sched/core.c and in<br>
> sched/fair.c<br>
> I am concerned only with fair scheduler. There are so many functions in<br>
> these two files that I am totally confused.<br>
<br>
</span>Then core.c and fair.c is the best bet.<br>
<br>
You could also pick up a copy of Linux kernel development (By Love), it<br>
gives a nice introduction to the overall flow of .. well mostly everything.<br>
:)<br>
<br>
In kernel/sched/sched.h you have a struct called 'struct sched_class" which<br>
is a set of function-points. This is used by the core machinery to call<br>
into scheduling-class specific code. At the bottom of fair.c, you see said<br>
struct being populated.<br>
<br>
Also, if you want to see what really happens, try enabling<br>
function-tracing, but limit it to sched-functions only (and sched-events,<br>
those are also useful to see what triggers things)<br>
<br>
mount -t debugfs nodev /sys/kernel/debug<br>
cd /sys/kernel/debug/tracing<br>
echo 0 > tracing_on<br>
echo function > current_tracer<br>
echo "sched*" > set_ftrace_filter<br>
echo 1 > events/sched/enable<br>
echo 1 > tracing_on<br>
... wait for a few secs<br>
echo 0 > tracing_on<br>
<br>
cat trace > /tmp/trace.txt<br>
<br>
Now, look at trace.txt and correlate it to the scheduler code :)<br>
<br>
Good luck!<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Henrik Austad<br>
</font></span></blockquote></div><br></div>