How can I ensure that a process runs in a specific physical CPU core and thread?
This question asks about ensuring two processes run on the same CPU. Using sched_setaffinity I can limit a process to a number of logical CPUs, but how can I ensure that these are mapped to specific physical CPUs and threads? I expect that the mapping would be: 0 - CPU 0 thread 0 1 - CPU 0 thread 1 2 - CPU 1 thread 0 3 - CPU 1 thread 1 etc... where the number on the left is the relevant CPU used in sched_setaffinity . However, when I tried to test this, it appeared that this is not necessarily the case. To test this, I used the CPUID instruction, which returns the initial APIC ID of the