Re: Process scheduling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: Digital signature

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux