English 中文(简体)
CPU Numbering on a hypertheading enabled system
原标题:

I am trying to find out how an OS (Windows, linux) assigns numbers to logical cpus in a Hyper threading enabled environment. ?

Does both the OSs first serially assign numbers to the Physical CPUs and then start numbering the logical cpus or is there some other rule followed.. ? e.g. in 2 physical cpu system with hyper threading , does an OS assign number 0,2 to the first physical cpu and then 1,3 to second physical cpu .. ?

Any references would be really appreciated.

Thanks in advance.

Regards, -Jay.

Edit: Responding to Alan s question : I need to know this because, In my work I need to bind various threads to specific CPUs to avoid context switches and I want to make sure that certain Tasks( THreads ) are bound to separate physical cpus. Thanks

最佳回答

From what I know, it depends on how the CPU exposes his cores. When HT is enabled, there are no exposed physical CPUs, but rather two logical CPUs per physical CPU, so there is no difference if you run a thread on either logical CPU. The only thing that does matter is what pairs of logical CPUs belong to each physical CPU.

With single core processors (like the Pentium 4 with HT), it s pretty straight forward, since you only have one pair - so it s (0, 1). With quad core processors (like Nehalem), the logical cores pairs are (0,4), (1,5), (2,6) and (3,7). The pattern of having all the first halves of each pair then having all the second halves shuold scale with future CPUs that have even more cores.

The real question is why do you need to know the pair arrangement? Let the OS s scheduler pick the right cores for the right threads - it does a pretty decent job.

问题回答

You can look in /sys/devices/system/cpu/ to find the information about the CPUs. The layout of the cores and their hyperthreaded pairs can be found in /sys/devices/system/cpu/cpuN/topology/thread_siblings_list.





相关问题
Why running a service as Local System is bad on windows?

I am trying to find out the difference between difference service account types. I tumbled upon this question. The answer was because it has powerful access to local resources, and Network Service ...

Programmatically detect Windows cluster configuration?

Does anyone know how to programatically detect that a Windows server is part of a cluster? Further, is it possible to detect that the server is the active or passive node? [Edit] And detect it from ...

get file icon for Outlook appointment (.msg)

I ve read Get File Icon used by Shell and the other similar posts - and already use SHFileInfo to get the associated icon for any given extension, and that works great. However, Outlook uses ".msg" ...

Identifying idle state on a windows machine

I know about the GetLastInputInfo method but that would only give me the duration since last user input - keyboard or mouse. If a user input was last received 10 minutes ago, that wouldn t mean the ...

Terminating a thread gracefully not using TerminateThread()

My application creates a thread and that runs in the background all the time. I can only terminate the thread manually, not from within the thread callback function. At the moment I am using ...

热门标签