GetSystemInfo(在Windows上)总是返回逻辑处理器的数量? [英] Does GetSystemInfo (on Windows) always return the number of logical processors?

查看:250
本文介绍了GetSystemInfo(在Windows上)总是返回逻辑处理器的数量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

阅读并阅读Microsoft文档,看起来它应该返回PHYSICAL处理器的数量,并且您应该使用GetLogicalProcessorInformation来确定您有多少LOGICAL处理器。



这是我在SYSTEM_INFO结构中找到的文档: http://msdn.microsoft.com/en-us/library/ms724958(v = VS.85).aspx
这里是GetLogicalProcessorInformation的文档:(空格添加了以通过垃圾邮件过滤器)
http:// msdn.microsoft。 com / en-us / library / ms683194.aspx



进一步阅读,在我在这个主题上发现的大多数讨论中,开发人员说GetSystemInfo(和SYSTEM_INFO结构)报告了LOGICAL处理器的数量。



当我再次搜索时,我发现MS发布了一些信息热修复),此处(通过垃圾邮件过滤器添加的空格):
http:// support 。 microsoft.com/ kb / 936235



读取它,听起来像Xp,服务前的Pack 3,GetSystemInfo报告的LOGICAL处理器的数量SYSTEM_INFO结构。它还读到我在Windows Vista和Windows 7,GetSystemInfo应该报告的物理处理器的数量(不同于Windows XP的服务前的包3)。



任何人都知道它实际上是什么?
GetSystemInfo是否真的根据运行的操作系统报告物理处理器的数量(在同一台计算机上)?

解决方案

读取,听起来像Xp,服务前的包3,GetSystemInfo报告在SYSTEM_INFO结构中的LOGICAL处理器的数量。它也读取到在Windows Vista和Windows 7,GetSystemInfo应该报告的物理处理器的数量(不同于Windows XP的服务前包3)。


这是正确的。 Windows XP SP2之前)没有区分逻辑处理器和物理处理器。 (毕竟,在发布Windows XP时,逻辑处理器不存在)因此,当函数返回操作系统认为是物理处理器的时候,SP2之前没有区别。



我相信为了保持兼容性,XP SP2 +继续报告该特定功能的逻辑处理器,因为这是应用程序期望它为XP机器做的。它更快,更容易问,我在XP吗?而不是问我在XP SP3上吗?。



为什么SP2和SP3之间的区别?尽管处理了SP2中物理和逻辑处理器之间的区别,这种变化只影响平台SKU的计费方式。基本上,在XP系统中最多可以有32个逻辑处理器,但SP2后最多只能有2个物理处理器。在SP2之前,您只能使用2个逻辑处理器。但是,在发布SP3之前,操作系统没有在API中公开这个功能。



很长的故事,如果你想得到逻辑处理器,pre SP3,物理处理器 - 操作系统不知道任何差异。在SP3后,调用 GetLogicalProcessorInformation 。如果你想得到物理处理器,SP3之前你想要的是不可能的( EDIT:至少与win32 apis)。 Post SP3当然可以调用 GetLogicalProcessorInformation


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?

解决方案

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.

这篇关于GetSystemInfo(在Windows上)总是返回逻辑处理器的数量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆