thread/process & memory management source code
das at FreeBSD.ORG
Sun Nov 30 03:07:11 PST 2003
[Redirected to threads@; please avoid spamming multiple lists.]
On Sat, Nov 29, 2003, Jay Sern Liew wrote:
> Can someone point to me the specific location in the FreeBSD kernel source
> where the code for FreeBSD's thread/process & memory management are?
> Specifically, where the dispatcher and scheduler is implemented,
> what kind of scheduling algorithms(short term, long term) are used,
> where the dynamic storage allocation algorithm is implemented(I'll try
> to figure the algorithm used from the code), etc.
For short term scheduling, FreeBSD uses the standard Unix
decay-usage priority scheduling. There is also an experimental
scheduler called ULE, which is designed to work better on SMPs.
ULE uses an ad hoc idea about how ``interactive'' a process is in
order to make scheduling decisions. See kern_switch.c,
sched_4bsd.c, sched_ule.c in src/sys/kern.
Long term scheduling is less important than it used to be, but
FreeBSD has a swapout daemon that kicks in when the system can't
recover enough memory by paging alone. It will basically swap out
every process it can that is idle and hasn't already been swapped
out recently. Swapping in occurs according in the order of a
priority that is based on the interactivity of the process, the
time it has been swapped out, and its nice value. See
The primary kernel memory allocator is a slab allocator. See
src/sys/vm/uma_*.c, src/sys/kern/kern_malloc.c, and
More information about the freebsd-arch