c# STILL returning wrong number of cores

邮差的信 提交于 2019-12-05 09:01:07

Thanks for your assistance, but I've found the problem. As I expected, it was due to AMDs design. They're using a new architecture called MCM (multi chip module I think) that causes Windows to not correctly identify the number of cores. I'm posting this as a solution in case anyone else runs into it. A work collegue directed me to a hotfix available at http://support.microsoft.com/kb/2711085

Before Windows 7/Windows Server 2008 R2, the maximum number of logical processors was limited to the size of a CPU register: 32 for the 32-bit operating system, 64 for the 64-bit system. This was because it's easy to do atomic operations on a single register-sized value.

For compatibility with 32-bit applications that assumed the number of processors could never be more than 32, the SYSTEM_INFO structure's dwNumberOfProcessors structure returned by GetSystemInfo was capped at 32. A 32-bit process can call GetNativeSystemInfo to get the 64-bit view. .NET's Environment.ProcessorCount property calls GetSystemInfo.

Windows 7/2008 R2 use an updated kernel that changes the number of supported processor cores from 64 to 256, and does away with some of the core locks. For compatibility with older applications, Windows 7 introduces the concept of a processor group. All the old APIs that dealt with processor masks now operate on the processors within the process's group, rather than on all processors. With 64 processors or fewer, there is only one group, but Windows 7 supports up to 4 groups. Windows 8/Server 2012 supports 10. (The 32-bit OS cannot use more than 32 logical processors, and always has one group.) If you want to find out the actual number of cores and their arrangement, you have to call GetActiveProcessorCount.

I can't find any information explicitly saying so, but I would expect NUMBER_OF_PROCESSORS to be capped for the same reason, and that a 32-bit process would be given an environment capped at 32.

Windows Server 2008 R2 is really a misnomer. It implies that there are minimal changes in the core of Windows compared to Windows Server 2008, and that just isn't true.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!