views:

373

answers:

1

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

+4  A: 

System.Environment.ProcessorCount Which will also include hyperthreaded processors. Which Vmware may or may not expose. Chances are higher that it will be exposed if the the processor is VT enabled AND you are using a baremetal enabled hypervisor technology.

If you have XP-SP3/WIN2k3 or above You can use WMI to pull out:

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.

You can start exploring how to pull out WMI info in .NET from this tutorial.

Hassan Syed
I know WMI, thanks. I'll try this, it may work. Strange this is, both taskmgr and CPU-Z give the same amount of processors. But CPU-Z shows one core per processor and I'm positive the type is originally (physically) a quadcore. This may be tricky to get right.
Abel
Give this a look:http://software.intel.com/en-us/articles/hyper-threading-technology-and-multi-core-processor-detection/I havent watched the videos. I have a suspicion that you are using a vmware software or version that is not VT enabled, or it is disabled in the bios. in this case it is merely scheduling your VM artificially on two cores.
Hassan Syed
http://communities.vmware.com/docs/DOC-5101 some discussion on hyperthreading and ESX if you are using that as your baremetal hypervisor, showing that ESX can schedule VM's onto virtual cores. It is mentioned that virtual cores aren't used untill demand exceeds cores available. I wonder how things would work on VT enabled processors, hmm. If I remember correctly you can bind VM's in ESX to specific processors.
Hassan Syed
I accept this as answer, because it answers the question. From various sources and other questions I gathered that it is not (trivially) possible to get the information I was after from within a VM.
Abel