SCHED_4BSD(9)
π SCHED_4BSD β the 4.4BSD thread scheduler β¨
okay so bestie, welcome to the sched_4bsd page from the Kernel Developer's Manual π β yes it's a section 9 manpage, yes it's about the kernel's vibes-based (no, actually very much algorithm-based, ngl) thread scheduler. buckle up π¦
β¨ NAME β¨
sched_4bsd β the classic 4.4BSD thread scheduler, the OG main character of kernel scheduling π
πΈ SYNOPSIS πΈ
#include <sys/sched.h>
void
resetpriority(lwp_t *l);
void
sched_tick(struct cpu_info *ci);
void
sched_schedclock(lwp_t *l);
void
sched_pstats_hook(struct proc *p, int minslp);
void
sched_setrunnable(lwp_t *l);
void
updatepri(lwp_t *l);
like, that's the whole cast of characters π
π DESCRIPTION π
So the traditional 4.4BSD scheduler uses a βmultilevel feedback queuesβ algorithm β and honestly its whole personality is: it favours interactive, short-running threads over CPU-bound ones. lowkey biased but in a cute way π«Ά. the chatty little threads get priority, the CPU hogs get pushed back, iykyk.
resetpriority()β recomputes the priority of a thread that's running in user mode. and if the resulting priority is higher than that of the current thread? π a reschedule gets arranged. politely. but firmly.sched_tick()β gets called fromhardclock(9)every100msto force a switch between equal priority threads. it's giving referee energy πsched_schedclock()β this is where the current thread's priority gets adjusted. heads up: the priority of a thread gets worse as it accumulates CPU time. yes literally, the more CPU you eat the more the scheduler side-eyes you πsched_pstats_hook()β gets called fromsched_pstats()everyHzticks, all so it can recompute the priorities of all the threads. group project energy, everyone gets recalculated β¨sched_setrunnable()β checks if an LWP has slept for more than one second π. if it has, its priority gets updated byupdatepri(). nap girlies stay winning π§
β EXAMPLES β
wanna know which scheduler is currently in use? bestie just ask it:
$ sysctl kern.sched.name
kern.sched.name = 4.4BSD
slay, confirmed 4.4BSD π₯
π CODE REFERENCES π
The 4.4BSD scheduler subsystem is implemented within the file sys/kern/sched_4bsd.c β that's where the magic lives, go read it π
π SEE ALSO π
and if you're feeling academic (respect, honestly π): Marshall Kirk McKusick, Keith Bostic, Michael J. Karels, and John S. Quarterman, The Design and Implementation of the 4.4BSD Operating System, Addison Wesley, 1996.
π fr fr if you're touching this, remember: priority isn't a personality, it changes. don't hardcode assumptions about it, bestie.
okay that's the whole page, you ate that π stay iconic, read your manpages, and remember β this little number shipped on Debian, dated April 9, 2019 ποΈπΈ bye bestie, mwah π«Άπ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2002 The NetBSD Foundation, Inc
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms