Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
992 views
in Technique[技术] by (71.8m points)

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

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.

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.

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

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

TaskManager

Update 2015-05-26:

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There may be a hint in the docs:

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

Could that be the issue here?

MSDN Article

Found something else interesting:

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.

MSDN Forum Post


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...