Показать полную графическую версию : [решено] Environment.ProcessorCount
SmallGod
19-10-2010, 23:11
Что будет выдавать св-во "System.Environment.ProcessorCount" например на процессорах Intel Core i5/i7
кол-во ядер процессора или доступных потоков?
Если количество ядер, то как получить кол-во потоков?
Delirium
20-10-2010, 01:00
Что значит, количество потоков? Какие потоки интересуют? Не совсем понятен вопрос :)
SmallGod
20-10-2010, 01:35
Что значит, количество потоков? Какие потоки интересуют? »
кол-во потоков (или логических процессоров) способных одновременно обрабатываться на процессоре.
Думаю, речь про hyperthreading. Очевидно, такой перевод.
SmallGod
20-10-2010, 07:49
Думаю, речь про hyperthreading »В общем да.
В Wbem, начиная [к сожалению, только] с Vista [про корректные данные — см. обсуждение ниже], в класс «Win32_Processor» добавили соответствующие свойства:
…
NumberOfCores
Data type: uint32
Access type: Read-only
Number of cores for the current instance of the processor. A core is a physical processor on the integrated circuit. For example, in a dual-core processor this property has a value of 2. For more information, see Remarks.
Windows Server 2003, Windows XP, and Windows 2000: This property is not available.
NumberOfLogicalProcessors
Data type: uint32
Access type: Read-only
Number of logical processors for the current instance of the processor. For processors capable of hyperthreading, this value includes only the processors which have hyperthreading enabled. For more information, see Remarks.
Windows Server 2003, Windows XP, and Windows 2000: This property is not available.
…
Remarks
To determine the total number of processor instances associated with a computer system object, use the Win32_ComputerSystemProcessor association class.
To determine if hyperthreading is enabled for the processor, compare NumberOfLogicalProcessors and NumberOfCores. If hyperthreading is enabled in the BIOS for the processor, then NumberOfCores is less than NumberOfLogicalProcessors. For example, a dual-processor system that contains two processors enabled for hyperthreading can run four threads or programs or simultaneously. In this case, NumberOfCores is 2 and NumberOfLogicalProcessors is 4.
…
SmallGod
20-10-2010, 20:58
В Wbem, начиная [к сожалению, только] с Vista »На сколько я знаю в XP SP3 тоже есть.
Так что же всё таки выдаёт System.Environment.ProcessorCount?
SmallGod, Возвращает число процессоров на текущем компьютере.
http://msdn.microsoft.com/ru-ru/library/system.environment.processorcount.aspx
На сколько я знаю в XP SP3 тоже есть. »
Спасибо. Действительно так:
wmic path Win32_Processor get NumberOfLogicalProcessors,NumberOfCores
NumberOfCores NumberOfLogicalProcessors
2 2
wmic computersystem get NumberOfProcessors,NumberOfLogicalProcessors
NumberOfLogicalProcessors NumberOfProcessors
2 1
Что касается конкретно Windows XP, то судя по KB936235: The number of physical hyperthreading-enabled processors or the number of physical multicore processors is incorrectly reported in Windows XP (http://support.microsoft.com/kb/936235/), включённому в SP3: Список исправлений, включенных в Windows XP с пакетом обновления 3 (http://support.microsoft.com/kb/946480), эти свойства действительно появились в SP3/SP2+KB936235:
…
Before you apply this hotfix, the WMI classes and the WMI properties exhibit the following behavior.
Win32_ComputerSystem
* The NumberOfProcessors property returns the number of logical processors that are available on the system.
* The NumberOfLogicalProcessors property is not available.
Win32_Processor
* The NumberOfLogicalProcessors property is not available.
* The NumberOfCores property is not available.
* The number of Win32_Processor instances that are returned is equal to the number of logical processors that are available on the system.
After you apply this hotfix, the WMI classes and the WMI properties exhibit the following behavior.
Win32_ComputerSystem
* The NumberOfProcessors property returns the number of physical processors that are available on the system.
* The NumberOfLogicalProcessors property returns the number of logical processors that are available on the system.
Win32_Processor
* The NumberOfLogicalProcessors property returns the number of logical processors on the current instance.
* The NumberOfCores property returns the number of cores on the current instance.
* The number of Win32_Processor instances that are returned is equal to the number of physical processors that are available on the system.
To determine whether hyperthreading is enabled for the processor, compare the value of the NumberOfCores property to the value of the NumberOfLogicalProcessors property. If hyperthreading is enabled in the basic input/output system (BIOS) for the processor, the value of the NumberOfCores property is less than the value of the NumberOfLogicalProcessors property.
For example, assume that a dual-processor system contains two processors that are each enabled for hyperthreading. This system can run four threads or four programs at the same time. In this case, the value of the NumberOfCores property is 2, and the value of the NumberOfLogicalProcessors property is 4.
Возможно, есть аналогичный же HotFix и под «Windows Server 2003»?!
Добавлено: ага, вот и аналогичная же статья, KB932370: The number of physical hyperthreading-enabled processors or the number of physical multicore processors is incorrectly reported in Windows Server 2003 (http://support.microsoft.com/kb/932370/).
Что касается «System.Environment.ProcessorCount» aka «%NUMBER_OF_PROCESSORS%», то опять же, речь идёт, скорее, о логических процессорах:
set num
NUMBER_OF_PROCESSORS=2
Впрочем, я не представляю, где реально можно посмотреть на машину с XP на многопроцессорной машине. Разве что попробовать проделать сию установку специально.
P.S. Все вышеприведённые примеры — для «Windows XP SP3».
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.