The traditional
4.4BSD scheduler employs a “multilevel feedback queues” algorithm, favouring interactive, short-running threads to CPU-bound ones.
resetpriority() recomputes the priority of a thread running in user mode. If the resulting priority is higher than that of the current thread, a reschedule is arranged.
sched_tick() gets called from
hardclock(9) every 100ms to force a switch between equal priority threads.
The priority of the current thread is adjusted through
sched_schedclock(). The priority of a thread gets worse as it accumulates CPU time.
sched_pstats_hook() gets called from
sched_pstats() every Hz ticks in order to recompute the priorities of all threads.
sched_setrunnable() checks if an LWP has slept for more than one second. If so, its priority is updated by
updatepri().