0
I am a bit confused about CPU logical cores and physical cores and scheduler affinity. Let's assume there is a 4 physical core CPU where each core supports 2 hyperthreads. Henceforth, according to /cpu/procinfo
logical core 0 and logical core 8 are inherently the same physical core.
Now, assume two threads:
Case I: the two threads are launched pthread_attr_setaffinity_np
with logical core 0.
Case II: One thread is launched with pthread_attr_setaffinity_np
with logical core 0 and another with logical core 8
Would there be any difference in both cases?
Why would that happen? On the hardware level, the physical core doesn't have the concept of logical cores. It just tries to execute as much instruction from the multiple execution contexts available to it. – Tushar Goyal – 2018-02-11T00:14:03.967
@TusharGoyal On the hardware level, the physical core has two sets of everything that's specific to a logical thread such as registers. Those two sets of execution contexts share execution units. If both threads are using the same logical core, only one execution context is available to the physical core at a time. If each thread is on a different logical core, then both execution contexts are available to the physical core at the same time. – David Schwartz – 2018-02-11T03:44:01.070