From: henrik@austad.us (Henrik Austad)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Process scheduling
Date: Sat, 13 Feb 2016 09:49:04 +0100 [thread overview]
Message-ID: <20160213084904.GB21526@icarus.home.austad.us> (raw)
In-Reply-To: <CAKfJ7KKcBRg1nKQwfAwL0N_bfb-GAa39sVLfFu=ykea1t3yv_A@mail.gmail.com>
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 --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20160213/5c031fa3/attachment.bin
next prev parent reply other threads:[~2016-02-13 8:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-13 6:12 Process scheduling Nitin Varyani
2016-02-13 8:49 ` Henrik Austad [this message]
2016-02-13 9:42 ` Nitin Varyani
[not found] ` <CAKfJ7KLrDSLuw-8CQg4jvKdnPRvQqAXHE4Wf+sSZYqJYdzn3dg@mail.gmail.com>
2016-02-15 12:37 ` Nitin Varyani
2016-02-17 6:10 ` Mulyadi Santosa
2016-02-17 7:18 ` Nitin Varyani
2016-02-17 16:23 ` Greg KH
2016-02-17 21:11 ` Boyan Vladinov
2016-02-17 21:13 ` Boyan Vladinov
-- strict thread matches above, loose matches on Subject: below --
2016-02-08 8:50 Process Scheduling Nitin Varyani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160213084904.GB21526@icarus.home.austad.us \
--to=henrik@austad.us \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).