.NET - [решено] Environment.ProcessorCount

Ответить
Аватара пользователя
Delirium

.NET - [решено] Environment.ProcessorCount

Сообщение Delirium »

Что будет выдавать св-во "System.Environment.ProcessorCount" например на процессорах Intel Core i5/i7

кол-во ядер процессора или доступных потоков?



Если количество ядер, то как получить кол-во потоков?
Аватара пользователя
Delirium

Re: .NET - [решено] Environment.ProcessorCount

Сообщение Delirium »

Что значит, количество потоков? Какие потоки интересуют? Не совсем понятен вопрос Изображение
Аватара пользователя
SmallGod

Re: .NET - [решено] Environment.ProcessorCount

Сообщение SmallGod »

Цитата Delirium:



Что значит, количество потоков? Какие потоки интересуют?
.NET - [решено] Environment.ProcessorCount




кол-во потоков (или логических процессоров) способных одновременно обрабатываться на процессоре.
Аватара пользователя
Iska

Re: .NET - [решено] Environment.ProcessorCount

Сообщение Iska »

Думаю, речь про hyperthreading. Очевидно, такой перевод.
Аватара пользователя
SmallGod

Re: .NET - [решено] Environment.ProcessorCount

Сообщение SmallGod »

Цитата Iska:



Думаю, речь про hyperthreading
.NET - [решено] Environment.ProcessorCount




В общем да.
Аватара пользователя
Iska

Re: .NET - [решено] Environment.ProcessorCount

Сообщение Iska »

В Wbem, начиная [к сожалению, только] с Vista [про корректные данные — см. обсуждение ниже], в класс «Win32_Processor» добавили соответствующие свойства:


читать дальше »



Цитата Win32_Processor Class:





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

Re: .NET - [решено] Environment.ProcessorCount

Сообщение SmallGod »

Цитата Iska:



В Wbem, начиная [к сожалению, только] с Vista
.NET - [решено] Environment.ProcessorCount




На сколько я знаю в XP SP3 тоже есть.

Так что же всё таки выдаёт System.Environment.ProcessorCount?
Аватара пользователя
lxa85

Re: .NET - [решено] Environment.ProcessorCount

Сообщение lxa85 »

SmallGod, Возвращает число процессоров на текущем компьютере.



http://msdn.microsoft.com/ru-ru/libr...ssorcount.aspx
Аватара пользователя
Iska

Re: .NET - [решено] Environment.ProcessorCount

Сообщение Iska »

Цитата SmallGod:



На сколько я знаю в XP SP3 тоже есть.
.NET - [решено] Environment.ProcessorCount




Спасибо. Действительно так:


читать дальше »




Код:

Код: Выделить всё

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
, включённому в SP3:
Список исправлений, включенных в Windows XP с пакетом обновления 3
, эти свойства действительно появились в SP3/SP2+KB936235:


читать дальше »



Цитата KB936235:





Before you apply this hotfix, the WMI classes and the WMI properties exhibit the following behavior.[/i]



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
.





Что касается «System.Environment.ProcessorCount» aka «%NUMBER_OF_PROCESSORS%», то опять же, речь идёт, скорее, о логических процессорах:



Код:

Код: Выделить всё

set num
NUMBER_OF_PROCESSORS=2

Впрочем, я не представляю, где реально можно посмотреть на машину с XP на многопроцессорной машине. Разве что попробовать проделать сию установку специально.



P.S. Все вышеприведённые примеры — для «Windows XP SP3».[/i]
Ответить

Вернуться в «Программирование и базы данных»