本文介绍了C#Environment.ProcessorCount并不总是返回完整的数字逻辑处理器的,为什么呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的机器上,Windows 7的 - 企业,1个英特尔至强E5-1660 0 @ 3.30Ghz(6核心/ CPU超线程激活),Environment.ProcessorCount返回12,是精确的。

On my machine, windows 7 - Enterprise with 1 x Intel Xeon E5-1660 0 @ 3.30Ghz (6 cores/cpu with Hyper Threading activated), Environment.ProcessorCount return 12 which is exact.

在一个Windows Server 2012中有2个英特尔至强E5-2697 V3 @ 2.60GHz(14核/ CPU超线程激活的(我想是因为任务管理器显示:2个插槽,28核,56逻辑处理器)),Environment.ProcessorCount返回28这似乎给我们的错,因为2x14x2 = 56。

On a Windows Server 2012 with 2 x Intel Xeon E5-2697 v3 @ 2.60GHz (14 cores/cpu with Hyper Threading activated(I think because task manager show: 2 sockets, 28 cores, 56 logical processors)), Environment.ProcessorCount return 28 which appears to us as wrong because 2x14x2 = 56.

为什么在Windows Server 2012中的C#方法Environment.ProcessorCount不返回正确的?逻辑处理器的数目

Why on Windows Server 2012 c# method Environment.ProcessorCount does not return the proper number of logical processors?

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

As Additional information, environment variables are as follows:NUMBER_OF_PROCESSORS=28

更新2015- 05-26:

有一个更详细信息/在我的其他问题本次关联错误的原因:的。主要是我认为C#中只能使用一个处理器组。什么是werid是,我们的服务器上,有2处理器组虽然只有56个逻辑处理器。但是,这解释为什么我们的服务器。BIOS配置是在错误诱导窗口

There is a more details/reasons of this related bug in my other question: Unable to use more than one processor group for my threads in a C# app. 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 explain why our server bios configuration were inducing windows in error.

推荐答案

有可能会在文档中的提示:

There may be a hint in the docs:

如果当前的机器包含多个处理器组,此属性返回逻辑处理器的数目可用作为由公共语言运行时(CLR)中使用。

"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)."

莫非是这里的问题?

找到东西其他有趣的:

默认情况下,池被限制在一个单一的处理器组(的),因此64个内核。然而,在.NET 4.5,您可以设置启用=真标志Thread_UseAllCpuGroups。

By default, the pool is restricted to a single processor group (http://msdn.microsoft.com/en-us/library/windows/desktop/dd405503(v=vs.85).aspx), and thus to 64 cores. However, in .NET 4.5 you can set the Thread_UseAllCpuGroups enabled="true" flag.

这篇关于C#Environment.ProcessorCount并不总是返回完整的数字逻辑处理器的,为什么呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 16:07