Export (0) Print
Expand All
Expand Minimize

KeGetProcessorNumberFromIndex routine

The KeGetProcessorNumberFromIndex routine converts a systemwide processor index to a group number and a group-relative processor number.

Syntax


NTSTATUS KeGetProcessorNumberFromIndex(
  _In_   ULONG ProcIndex,
  _Out_  PPROCESSOR_NUMBER ProcNumber
);

Parameters

ProcIndex [in]

A systemwide processor index. If a multiprocessor system contains a total of n logical processors, valid processor indexes range from 0 to n-1.

ProcNumber [out]

A pointer to a caller-allocated PROCESSOR_NUMBER structure into which the routine writes the group number and group-relative processor number of the processor that is identified by ProcIndex.

Return value

KeGetProcessorNumberFromIndex returns STATUS_SUCCESS if the call is successful. Possible error return values include the following:

Return codeDescription
STATUS_INVALID_PARAMETER

The ProcIndex parameter value is not a valid processor index.

 

Remarks

This routine accepts as input a processor index that identifies the processor across the entire multiprocessor system. The output value is a PROCESSOR_NUMBER structure that identifies a processor by its group number and its processor number within the group.

For example, if a multiprocessor system contains two groups, and each group contains 64 logical processors, the processor numbers in each group range from 0 to 63, but the systemwide processor indexes range from 0 to 127.

To obtain the total number of active logical processors in the system, call the KeQueryActiveProcessorCountEx routine.

The KeGetProcessorIndexFromNumber routine converts a group number and a group-relative processor number to a systemwide processor index.

Examples

The following code example uses the KeQueryActiveProcessorCountEx and KeGetProcessorNumberFromIndex routines to enumerate all active logical processors in the system:


ULONG Count;
ULONG ProcIndex;
PROCESSOR_NUMBER ProcNumber;

Count = KeQueryActiveProcessorCountEx(ALL_PROCESSOR_GROUPS);
for (ProcIndex = 0; ProcIndex < Count; ProcIndex += 1)
{
    KeGetProcessorNumberFromIndex(ProcIndex, &ProcNumber);

    // Do something with the contents of ProcNumber.
    ...
}

The constant value ALL_PROCESSOR_GROUPS is defined in Winnt.h and Ntdef.h.

Requirements

Version

Available in Windows 7 and later versions of Windows.

Header

Wdm.h (include Ntddk.h, Wdm.h, or Ntddk.h)

Library

Ntoskrnl.lib

IRQL

Any level

See also

KeGetProcessorIndexFromNumber
KeQueryActiveProcessorCountEx
PROCESSOR_NUMBER

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft