简体   繁体   English

如何以编程方式确定是在多核,超线程还是在多处理器上?

[英]How can I determine programmatically whether on multi-core, hyperthreading or multi-processor?

I know how to get the processor type, perhaps that's the only way, but I'm actually looking for a way to determine from an application whether it's running on a multi-core processor or on a hyper-threading single-core processor . 我知道如何获取处理器类型,也许那是唯一的方法,但是我实际上是在寻找一种方法,从应用程序确定它是在多核处理器上运行还是在超线程单核处理器上运行

(background: the hosting providers of some of my clients are very vague about what resources they make available through VMWare images. This application is supposed to run on multi-core, but has seen detrimental performance since its last "move". Normally, on multi-core, one core spikes on one thread, and not the other. On this "multi-core", both processors spike, even on single-threaded applications.) (背景:我的一些客户的托管服务提供商非常不清楚他们通过VMWare映像提供了哪些资源。该应用程序应该在多核上运行,但是自上次“迁移”以来,其性能一直是不利的。)多核,一个核尖峰在一个线程上,而不是在另一个线程上。在这种“多核”上,两个处理器都在峰值,即使在单线程应用程序上也是如此。)

System.Environment.ProcessorCount Which will also include hyperthreaded processors. System.Environment.ProcessorCount还将包括超线程处理器。 Which Vmware may or may not expose. 哪个或哪些Vmware可能不会公开。 Chances are higher that it will be exposed if the the processor is VT enabled AND you are using a baremetal enabled hypervisor technology. 如果处理器启用了VT,并且您使用的是启用裸机的虚拟机管理程序技术,则很有可能会暴露出来。

If you have XP-SP3/WIN2k3 or above You can use WMI to pull out: 如果您具有XP-SP3 / WIN2k3或更高版本,则可以使用WMI退出:

Win32_ComputerSystem.NumberOfProcessors returns physical count

Win32_ComputerSystem.NumberOfLogicalProcessors returns logical count

If the values are the same then chances are your system does not have HT or does not have it enabled. 如果值相同,则可能是您的系统没有HT或未启用它。

You can start exploring how to pull out WMI info in .NET from this tutorial . 您可以开始探索如何从本教程中提取.NET中的WMI信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM