Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CPU Identification on Virtual Machine

I use following c# code to get processor information. The Management class is null if I run my application on a virtual machine. I use Oracle VM VirtualBox as my virtual pc (Windows XP SP3)

System.Management.ManagementClass Management = new System.Management.ManagementClass("Win32_Processor");

Does anyone has experience about using such code and has problems in virtual machines.

like image 865
Demir Avatar asked Jun 08 '11 11:06

Demir


People also ask

How does vmware calculate CPU?

To calculate the number of logical CPUs in vSphere Client, multiply the number of sockets by the number of cores. For example, if you need to configure a VM to use 2-processor sockets, each has 2 CPU cores, then the total number of logical CPUs is 2*2=4.

What is CPU in vmware?

CPU virtualization emphasizes performance and runs directly on the processor whenever possible. The underlying physical resources are used whenever possible and the virtualization layer runs instructions only as needed to make virtual machines operate as if they were running directly on a physical machine.


2 Answers

Oracle VirtualBox does not provide such information.

Here is the related ticket.

https://www.virtualbox.org/ticket/9046

like image 167
Demir Avatar answered Sep 30 '22 11:09

Demir


Are you using GetInstances?

System.Management.ManagementClass ManagementClass1 = new System.Management.ManagementClass("Win32_Processor");

System.Management.ManagementObjectCollection ManagementObjectCollection1 = ManagementClass1.GetInstances();

foreach (System.Management.ManagementObject managementobject in ManagementObjectCollection1) {
    Console.Out.WriteLine(managementobject.Properties["Name"].Value);
}

Console.In.ReadLine();
like image 29
BZ1 Avatar answered Sep 30 '22 10:09

BZ1