none
GetSystemInfo value for dwNumberOfProcessors

    Question

  • I have a computer that is returning 1 for the dwNumberOfProcessors from GetSystemInfo.  Other computers with the same OS, Chip and Service pack return 2. The CPUID instruction returns 2 for number of cores, it is a single dual core system.

    Does anyone know why I get these results, and how to Fix it?

    The computer is:
    XP 32bit SP3
    1 Intel T9400  (Dual Core)

    Thanks
    Alan
    Monday, May 11, 2009 3:05 PM

Answers

  • Hello Alan

    There are known issues with Windows XP and Windows Server 2003 that the number of physical hyperthreading-enabled processors or the number of physical multicore processors is incorrectly reported.

    http://support.microsoft.com/kb/936235
    http://support.microsoft.com/default.aspx/kb/932370/

    Would you please check whether the fix helps the case under discussion?

    Additionally, could you check the output of Msinfo32 on the computer that report only one logical processor?

    Thanks
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Tuesday, May 12, 2009 8:39 AM
  • Hi – I think my information can help you.

    I’ve just tested the following code (See code-snippet 1), and I got this print result: “NumberOfCores: 0”. That was when I used the Windows® Application Programming Interface (API), from kernel32.dll.

    ================================================================================
    Declaration:
    using
    System.Runtime.InteropServices;
    ================================================================================
    [
    DllImport("kernel32.dll"
    )]
    public static extern void GetSystemInfo([MarshalAs(UnmanagedType.Struct)] ref systeminfo
    lpSystemInfo);

    public
    struct systeminfo
    {
         public uint
    dwNumberOfProcessors;
    }
    ===========================================================================
    Usage:
    systeminfo sysinfo = new systeminfo
    ();
    label1.Text =
    "NumberOfCores: "
    + sysinfo.dwNumberOfProcessors.ToString();
    ================================================================================

    However, I manage to solve the problem through Windows Management Instrumentation (WMI).
    Anyway, try this solution:

    ==============================================================================================================
    Declaration: 
    using
    System.Management;
    ==============================================================================================================
    ManagementObjectSearcher search = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"
    );
    foreach (ManagementObject obj in
    search.Get())
    {
          label2.Text =
    "NumberOfCores: " + obj.GetPropertyValue("NumberOfCores"
    ).ToString();
    }
    ==============================================================================================================

    Note: Through WMI I got this result, “NumberOfCores: 2”.

    I hope my information helped you solve your problem…

    Have a nice day…

    Best regards,
    Fisnik


    Coder24.com
    Friday, May 22, 2009 11:41 AM

All replies

  • Task Manager shows 2 cores I assume?
    Michael Asher
    Monday, May 11, 2009 3:13 PM
  • Hello Alan

    There are known issues with Windows XP and Windows Server 2003 that the number of physical hyperthreading-enabled processors or the number of physical multicore processors is incorrectly reported.

    http://support.microsoft.com/kb/936235
    http://support.microsoft.com/default.aspx/kb/932370/

    Would you please check whether the fix helps the case under discussion?

    Additionally, could you check the output of Msinfo32 on the computer that report only one logical processor?

    Thanks
    Jialiang Ge
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Tuesday, May 12, 2009 8:39 AM
  • Hello Alan

    I am writing to check the status of the issue on your side. Would you mind letting me know the result of the suggestions? If you need further assistance, feel free to let me know. I will be more than happy to be of assistance.

    Have a great day!

    Jialiang Ge


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
    Friday, May 15, 2009 7:05 AM
  • Hi – I think my information can help you.

    I’ve just tested the following code (See code-snippet 1), and I got this print result: “NumberOfCores: 0”. That was when I used the Windows® Application Programming Interface (API), from kernel32.dll.

    ================================================================================
    Declaration:
    using
    System.Runtime.InteropServices;
    ================================================================================
    [
    DllImport("kernel32.dll"
    )]
    public static extern void GetSystemInfo([MarshalAs(UnmanagedType.Struct)] ref systeminfo
    lpSystemInfo);

    public
    struct systeminfo
    {
         public uint
    dwNumberOfProcessors;
    }
    ===========================================================================
    Usage:
    systeminfo sysinfo = new systeminfo
    ();
    label1.Text =
    "NumberOfCores: "
    + sysinfo.dwNumberOfProcessors.ToString();
    ================================================================================

    However, I manage to solve the problem through Windows Management Instrumentation (WMI).
    Anyway, try this solution:

    ==============================================================================================================
    Declaration: 
    using
    System.Management;
    ==============================================================================================================
    ManagementObjectSearcher search = new ManagementObjectSearcher("SELECT * FROM Win32_Processor"
    );
    foreach (ManagementObject obj in
    search.Get())
    {
          label2.Text =
    "NumberOfCores: " + obj.GetPropertyValue("NumberOfCores"
    ).ToString();
    }
    ==============================================================================================================

    Note: Through WMI I got this result, “NumberOfCores: 2”.

    I hope my information helped you solve your problem…

    Have a nice day…

    Best regards,
    Fisnik


    Coder24.com
    Friday, May 22, 2009 11:41 AM