我用4核8线程的电脑运行,dwNumberOfProcessors取到的是4,如果取到的是逻辑处理器数量不该是8吗[/quote]
估计你的电脑BIOS设置没开超线程,或者你在虚拟机里测试的
[/quote]
关于dwNumberOfProcessors,在MSDN上的解释是
The number of logical processors in the current group. To retrieve this value, use the GetLogicalProcessorInformation function.
其中提到了一个current group;
然后关于逻辑处理器有一段
Support for systems that have more than 64 logical processors is based on the concept of a processor group, which is a static set of up to 64 logical processors that is treated as a single scheduling entity. Processor groups are numbered starting with 0. Systems with fewer than 64 logical processors always have a single group, Group 0.
所以是否可能是因为我这台机器被分为了两个组,所以取到的dwNumberOfProcessors只是其中一个组的大小