Scheduling¶
The scheduler chooses which runnable thread executes on a CPU, coordinates
CPU placement and migration, and accounts for execution and priority changes.
Its machine-independent implementation is in sys/kern and its interface
is described in sys/sys/sched.h.
This checkout contains a scheduler-instance framework. The shim selects a registered implementation during boot and dispatches the scheduler interface to it. ULE and 4BSD provide different queueing and policy implementations behind that interface.
Finding the implementation¶
Source |
Responsibility |
|---|---|
|
Interface descriptions, dispatch macros, and instance registration. |
|
Boot selection, interface dispatch, and common scheduler information. |
|
ULE priorities, per-CPU queues, placement, migration, and balancing. |
|
4BSD priorities, global/per-CPU queues, and accounting. |
|
Machine-independent context-switch and runnable-state transitions. |
|
Priority-indexed run-queue primitives used by scheduler implementations. |
|
Waiting and lock-contention mechanisms that interact with scheduling. |
The execution unit is a thread. Process policy and nice values influence its treatment, but a process can contain multiple independently scheduled threads. A blocked thread is not simply a low-priority runnable thread.
The Virtual memory and Virtual file system guides show two common reasons
for a thread to block. Scheduler and VFS references both select the kern
Doxygen project; their reading topics and canonical API pages remain separate.