Does a thread run on the same CPU/core throughout its life?

multithreading, windows

Solution

does a thread change the CPU/core during its lifetime?

It can. It doesn't necessarily change, but there is nothing preventing the operating system from moving a thread between cores.

The Windows API does provide some control over this via SetThreadIdealProcessor or SetThreadAffinityMask and SetProcessAffinityMask, if you need to control a thread's operation.

Problem

In Windows on a multiprocessor machine, does a thread change the CPU/core during its lifetime?

Original source