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
Aka. SMP. Each CPU runs its own scheduler.
Models:
- Single global ready queue
- Per-CPU ready queues
Load Balancing
Distributes workload to all CPUs evenly. 2 types.
Push Migration
Work is pushed from overloaded CPUs to others, periodically.
Pull Migration
Idle CPUs pulls tasks from overloaded CPUs.
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
Process is free to be moved to another CPU if required.
Hard affinity
Process restricted to specific CPU(s).
Multicore Scheduling
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.