Choosing where a thread runs
By default the scheduler may move a thread between cores. CPU pinning, also called setting affinity, binds a thread to one core or a small set of cores so it stops migrating.
Why migration hurts
- Each core has its own fast cache. When a thread moves, the new core's cache is cold, so it stalls reloading data.
- Migrations also disturb branch predictors and other per core state.
Pinning keeps a thread's working set warm in one core's cache, which lowers and stabilizes latency.
Core isolation
For the most demanding work you go further and isolate a core. The OS is told to keep its normal threads and timer interrupts off that core, reserving it almost entirely for one pinned thread. Background kernel work runs elsewhere.
The trade off
Isolation gives one thread a near dedicated core with very steady timing, but it removes that core from the general pool. If your isolated thread is often idle, you have wasted capacity. It pays off only for latency critical paths that must run without interference.
Key idea
CPU pinning binds a thread to a core to keep its cache warm and timing steady, while core isolation reserves that core from the OS for latency critical work at the cost of general capacity.