views:

247

answers:

1

Reading up on this, and specifically reading the Microsoft docs, it looks like it should be returning the number of PHYSICAL processors, and that you should use GetLogicalProcessorInformation to figure out how many LOGICAL processors you have.

Here's the doc I found on the SYSTEM_INFO structure: http://msdn.microsoft.com/en-us/library/ms724958(v=VS.85).aspx And here's the doc on GetLogicalProcessorInformation: (spaces added to get through spam filter) http:// msdn.microsoft.com/ en-us/ library/ ms683194.aspx

Reading up on it further though, in most of the discussions I've found on this topic, developers say to that GetSystemInfo (and the SYSTEM_INFO structure) report the number of LOGICAL processors.

When I search again, I find that MS did release some info on this (and a hot fix), here (spaces added to get through spam filter): http:// support. microsoft.com/ kb/936235

Reading that, it sounds like on Xp, pre-service Pack 3, GetSystemInfo reports the number of LOGICAL processors in the SYSTEM_INFO structure. It also reads to me that on Windows Vista and Windows 7, GetSystemInfo should be reporting the number of PHYSICAL processors (different to Windows XP pre-service Pack 3).

Does anyone know what it actually does? Does GetSystemInfo really report the number of physical processors (on the same computer) differently, depending on which OS it's running on?

+1  A: 

Reading that, it sounds like on Xp, pre-service Pack 3, GetSystemInfo reports the number of LOGICAL processors in the SYSTEM_INFO structure. It also reads to me that on Windows Vista and Windows 7, GetSystemInfo should be reporting the number of PHYSICAL processors (different to Windows XP pre-service Pack 3).

That is correct. Windows XP pre SP2) does not make any distinction between logical and physical processors. (After all, logical processors did not exist when Windows XP was released) Therefore, while the function is returning what the OS thinks are "physical processors," there is no difference pre SP2.

I believe to maintain compatibility though, XP SP2+ continues to report logical processors for that particular function, because that is what applications expect it to do for XP machines. It's much faster and easier to ask, "Am I on XP?" than to ask "Am I on XP SP3?".

Why the difference here between SP2 and SP3? Despite dealing with the difference between physical and logical processors in SP2, that change only affected how platform SKUs are billed. Basically, you can have up to 32 logical processors in an XP system, but only 2 physical processors maximum post SP2. Before SP2, you were limited to 2 logical processors. However, the OS didn't expose this functionality in an API until SP3 was released.

Long story short, if you want to get logical processors, pre SP3, just get physical processors -- the OS does not know any difference. Post SP3, call GetLogicalProcessorInformation. If you want to get physical processors, pre SP3 what you want is not possible (EDIT: At least with win32 apis). Post SP3 of course you can call GetLogicalProcessorInformation.

Billy ONeal