ULE thread scheduling in -head
hiren panchasara
hiren.panchasara at gmail.com
Fri Nov 15 08:30:52 UTC 2013
I want to understand how thread affinity works and for that I need to
understand how scheduling works. I am reading things and trying to map
them to the code in FreeBSD-head (in and around sys/kern/sched_ule.c)
In terms of scheduler queues, I found 2 different things:
1)
"ULE: A Modern Scheduler For FreeBSD" paper from jeffr mentions
following in 3.1 Queue Mechanisms:
Fairness is implemented by keeping two queues; current and next. Each
thread that is granted a
slice is assigned to either the current queue or the next queue.
2)
I found another interesting struct in there: struct tdq - per
processor runqs and statistics which has 3 queues: realtime, timeshare
and idle.
I could not find 1) in source code.
Can someone throw some light on how a thread gets scheduled? Do 1) and
2) both exist and work together currently in -head FreeBSD?
Trying to follow the code, sched_setup() calls sched_setup_smp() where
for each cpu we call tdq_setup() where we initialize 3 queues
mentioned in 2) -- But it seems this is all one time setup on boot.
What happens when a new thread is spawned?
Any good pointer/reference for further reading would be great.
cheers,
Hiren
More information about the freebsd-hackers
mailing list