c# Environment.ProcessorCount 并不总是 return 逻辑处理器的完整数量,为什么?

c# Environment.ProcessorCount does not always return the full number of Logical Processor, why?

在我的机器上,windows 7 - Enterprise with 1 x Intel Xeon E5-1660 0 @ 3.30Ghz(6 cores/cpu 激活了超线程),Environment.ProcessorCount return 12 是准确的。

在 Windows Server 2012 上配备 2 x Intel Xeon E5-2697 v3 @ 2.60GHz(14 cores/cpu 激活了超线程(我认为是因为任务管理器显示:2 个插槽,28 个内核, 56 个逻辑处理器)), Environment.ProcessorCount return 28 在我们看来是错误的因为 2x14x2 = 56.

为什么 Windows Server 2012 c# 方法 Environment.ProcessorCount 没有 return 正确数量的逻辑处理器?

作为附加信息,环境变量如下: NUMBER_OF_PROCESSORS=28

2015-05-26更新:

在我的另一个问题中有更多 details/reasons 这个相关的错误:. Mainly I think that C# does only use one processor group. What's werid was that on our server, there was 2 processor groups although there was only 56 logical processors. But this HP CUSTOMER ADVISORY 解释为什么我们的服务器 bios 配置导致 windows 错误。

文档中可能有提示:

"If the current machine contains multiple processor groups, this property returns the number of logical processors that are available for use by the common language runtime (CLR)."

会不会是这里的问题?

MSDN Article

发现其他有趣的东西:

默认情况下,池仅限于单个处理器组 (http://msdn.microsoft.com/en-us/library/windows/desktop/dd405503(v=vs.85).aspx),因此限制为 64 个内核。但是,在 .NET 4.5 中,您可以设置 Thread_UseAllCpuGroups enabled="true" 标志。

MSDN Forum Post

检查您的系统NUMBER_OF_PROCESSORS 环境变量。那是什么方法returns。请参阅 MSDN 文章:http://msdn.microsoft.com/en-us/library/system.environment.processorcount%28v=vs.100%29.aspx(权限部分)。

根据 the MSDN docs on <Thread_UseAllCpuGroups>,您需要进行以下设置才能看到和使用所有 CPU 组:

<configuration>
   <runtime>
      <Thread_UseAllCpuGroups enabled="true"/>
      <GCCpuGroup enabled="true"/>
      <gcServer enabled="true"/>
   </runtime>
</configuration>