Expand description
Per-CPU Ready Queues with Work-Stealing
Eliminates the global scheduler lock by giving each CPU its own run queue. When a CPU’s queue is empty, it steals work from the busiest neighbor.
§Design
- Each CPU has a
PerCpuQueueprotected by a per-CPU spin lock AtomicU32run_length allows lock-free queue length queries- Work stealing takes half the victim’s queue (from the back)
- Steal threshold prevents thrashing on lightly loaded systems
Structs§
- PerCpu
Queue - Per-CPU run queue.
- PerCpu
Scheduler - Per-CPU scheduler managing all CPU queues.
Functions§
- percpu_
pop - Pop the next process from a CPU’s queue, with work-stealing fallback.
- percpu_
push - Push a process onto the appropriate CPU’s queue.