Scheduling becomes more complex when multiple CPUs/cores exist.
Multiple process means any one of:
- Multicore CPUs
- Multithreaded cores
- NUMA systems
- Heterogeneous multiprocessing
Symmetric Multiprocessing
Section titled “Symmetric Multiprocessing”Aka. SMP. Each CPU runs its own scheduler.
Models:
- Single global ready queue
- Per-CPU ready queues
Load Balancing
Section titled “Load Balancing”Distributes workload to all CPUs evenly. 2 types.
Push Migration
Section titled “Push Migration”Work is pushed from overloaded CPUs to others, periodically.
Pull Migration
Section titled “Pull Migration”Idle CPUs pulls tasks from overloaded CPUs.
Processor Affinity
Section titled “Processor Affinity”A scheduling mechanism. Controls which CPU or set of CPUs a process or thread is allowed or preferred to run on.
Scheduler would try to keep a thread in the same CPU as much as possible. For the performance boost due to cache locality. But might not be possible at all times.
Soft affinity
Section titled “Soft affinity”Process is free to be moved to another CPU if required.
Hard affinity
Section titled “Hard affinity”Process restricted to specific CPU(s).
Multicore Scheduling
Section titled “Multicore Scheduling”Two-level Scheduling
Section titled “Two-level Scheduling”A hybrid threading model. Scheduling happens in 2 levels.
- OS decided which software thread to run on a logical CPU
- Each core decides which hardware thread to run on the physical core.
Used in multithreaded multi-core systems.