Expand Minimize

KeQueryActiveProcessors routine

The KeQueryActiveProcessors routine returns a bitmask of the currently active processors.


KAFFINITY KeQueryActiveProcessors(void);


This routine has no parameters.

Return value

KeQueryActiveProcessors returns a KAFFINITY value that represents the set of currently active processors.


Callers cannot assume that KeQueryActiveProcessors maps processors to bits consecutively, or that the routine consistently uses the same mapping each time it is called. The only valid use for the return value is to determine the number of active processors by counting the number of bits that are set.

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

Windows 7 and later versions of Windows support processor groups. Drivers that are designed to handle information about processor groups should use the KeQueryGroupAffinity routine, which specifies a processor group, instead of KeQueryActiveProcessors, which does not. However, the implementation of KeQueryActiveProcessors 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, KeQueryActiveProcessors returns an affinity mask that specifies the set of active logical processors in group 0.

In Windows Vista and later versions of Windows, this routine can be called at any IRQL. However, in Windows Server 2003 and earlier versions of Windows, this routine must be called at IRQL <= APC_LEVEL.



Available starting with Windows 2000.


Ntddk.h (include Ntddk.h)




See Remarks section.

DDI compliance rules

IrqlKeApcLte1, HwStorPortProhibitedDDIs

See also




Send comments about this topic to Microsoft

© 2014 Microsoft