Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Программирование и базы данных (http://forum.oszone.net/forumdisplay.php?f=21)
-   -   [решено] Environment.ProcessorCount (http://forum.oszone.net/showthread.php?t=188807)

SmallGod 19-10-2010 23:11 1522676

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

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

Delirium 20-10-2010 01:00 1522726

Что значит, количество потоков? Какие потоки интересуют? Не совсем понятен вопрос :)

SmallGod 20-10-2010 01:35 1522737

Цитата:

Цитата Delirium
Что значит, количество потоков? Какие потоки интересуют? »

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

Iska 20-10-2010 06:01 1522787

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

SmallGod 20-10-2010 07:49 1522811

Цитата:

Цитата Iska
Думаю, речь про hyperthreading »

В общем да.

Iska 20-10-2010 11:41 1522955

В 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 20-10-2010 20:58 1523463

Цитата:

Цитата Iska
В Wbem, начиная [к сожалению, только] с Vista »

На сколько я знаю в XP SP3 тоже есть.
Так что же всё таки выдаёт System.Environment.ProcessorCount?

lxa85 20-10-2010 22:27 1523525

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

http://msdn.microsoft.com/ru-ru/libr...ssorcount.aspx

Iska 21-10-2010 00:02 1523570

Цитата:

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

Цитата 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.


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

set num
NUMBER_OF_PROCESSORS=2

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

P.S. Все вышеприведённые примеры — для «Windows XP SP3».


Время: 00:43.

Время: 00:43.
© OSzone.net 2001-