Process scheduling

Nitin Varyani varyani.nitin1 at gmail.com
Mon Feb 15 07:37:22 EST 2016


On Mon, Feb 15, 2016 at 6:06 PM, Nitin Varyani <varyani.nitin1 at gmail.com>
wrote:

> Hi
>         I have studied LInux kernel CFS scheduling algorithm - the
> vruntime, weights, nice value, etc. I am able to understand the code.
>  Actually the task given to me is really very huge. I am told to design a
> distributed process scheduling algorithm. A very simple implementation of
> it will be sufficient for me. Current distributed OS are patch work over
> the linux kernels, that is, they are responsible for load balancing through
> process migration but the scheduling is taken care by the single machine
> linux kernels. My task is to make the scheduling algorithm itself as
> distributed. That is a scheduler makes a decision whether to migrate a task
> or to keep the task in the current system.  I need some design aspects of
> how to achieve it. Another thing which I want to know is that whether this
> job is possible for a kernel newbie like me.
>
> On Sat, Feb 13, 2016 at 3:12 PM, Nitin Varyani <varyani.nitin1 at gmail.com>
> wrote:
>
>> thanks
>>
>> On Sat, Feb 13, 2016 at 2:19 PM, Henrik Austad <henrik at austad.us> wrote:
>>
>>> On Sat, Feb 13, 2016 at 11:42:57AM +0530, Nitin Varyani wrote:
>>> > Hello,
>>>
>>> Hi Nitin,
>>>
>>> >          I want to understand the flow of code of process scheduler of
>>> > linux kernel. What I have understood is that
>>> > The task marks itself as sleeping,
>>> > puts itself on a wait queue,
>>> > removes itself from the red-black tree of runnable, and
>>> > calls schedule() to select a new process to execute.
>>> >
>>> > for Waking back up
>>> > The task is set as runnable,
>>> > removed from the wait queue,
>>> > and added back to the red-black tree.
>>> >
>>> > Can I get the details of which function does what? in sched/core.c and
>>> in
>>> > sched/fair.c
>>> > I am concerned only with fair scheduler. There are so many functions in
>>> > these two files that I am totally confused.
>>>
>>> Then core.c and fair.c is the best bet.
>>>
>>> You could also pick up a copy of Linux kernel development (By Love), it
>>> gives a nice introduction to the overall flow of .. well mostly
>>> everything.
>>> :)
>>>
>>> In kernel/sched/sched.h you have a struct called 'struct sched_class"
>>> which
>>> is a set of function-points. This is used by the core machinery to call
>>> into scheduling-class specific code. At the bottom of fair.c, you see
>>> said
>>> struct being populated.
>>>
>>> Also, if you want to see what really happens, try enabling
>>> function-tracing, but limit it to sched-functions only (and sched-events,
>>> those are also useful to see what triggers things)
>>>
>>> mount -t debugfs nodev /sys/kernel/debug
>>> cd /sys/kernel/debug/tracing
>>> echo 0 > tracing_on
>>> echo function > current_tracer
>>> echo "sched*" > set_ftrace_filter
>>> echo 1 > events/sched/enable
>>> echo 1 > tracing_on
>>> ... wait for a few secs
>>> echo 0 > tracing_on
>>>
>>> cat trace > /tmp/trace.txt
>>>
>>> Now, look at trace.txt and correlate it to the scheduler code :)
>>>
>>> Good luck!
>>>
>>> --
>>> Henrik Austad
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160215/d8031e45/attachment-0001.html 


More information about the Kernelnewbies mailing list