KeQueryActiveProcessorCount function (ntddk.h)

The KeQueryActiveProcessorCount routine returns the number of currently active processors.

Syntax

ULONG KeQueryActiveProcessorCount(
  [out, optional] PKAFFINITY ActiveProcessors
);

Parameters

[out, optional] ActiveProcessors

A pointer to a KAFFINITY-typed variable into which the routine writes a bitmask that represents the set of currently active processors. In a hot-add environment, this mask may change during runtime. This parameter is optional and can be specified as NULL if the caller does not require the mask of active processors.

Return value

KeQueryActiveProcessorCount returns the number of currently active processors.

Remarks

A device driver calls the KeQueryActiveProcessorCount routine to retrieve the number of currently active processors. Device drivers that are built for Windows Vista and later versions of the Windows operating system should not use the KeNumberProcessors kernel variable for this purpose.

Callers cannot assume that the KeQueryActiveProcessorCount routine maps processors to bits in the returned KAFFINITY value consecutively, or that the routine will return the same bitmask each time it is called.

Callers must also be aware that the value returned by KeQueryActiveProcessorCount can change at runtime on versions of Windows that support hot-add CPU functionality.

If necessary, register for notification of changes to the number of processors by calling the KeRegisterProcessorChangeCallback routine.

To query just the affinity mask without getting the number of active processors, use KeQueryActiveProcessors.

Windows 7 and later versions of Windows support processor groups. Drivers that are designed to handle information about processor groups should use the KeQueryActiveProcessorCountEx routine, which specifies a processor group, instead of KeQueryActiveProcessorCount, which does not. However, the implementation of KeQueryActiveProcessorCount in Windows 7 and later versions of Windows provides compatibility for drivers that were written for earlier versions of Windows, which do not support processor groups. In this implementation, KeQueryActiveProcessorCount returns the number of active logical processors in group 0, and writes an affinity mask to *ActiveProcessors that specifies the set of active logical processors in group 0.

Requirements

Requirement Value
Minimum supported client Available in Windows Vista and later versions of Windows.
Target Platform Universal
Header ntddk.h (include Wdm.h, Ntddk.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL Any level

See also

KeQueryActiveProcessorCountEx

KeQueryActiveProcessors

KeRegisterProcessorChangeCallback