Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Nov 2013 00:30:49 -0800
From:      hiren panchasara <hiren.panchasara@gmail.com>
To:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>
Subject:   ULE thread scheduling in -head
Message-ID:  <CALCpEUFpOjGGw1Ys4fTyB24gRQ-ab3X_qzrTqUNpjBBSZnP84g@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CALCpEUFpOjGGw1Ys4fTyB24gRQ-ab3X_qzrTqUNpjBBSZnP84g>