GetNativeProcessorMaskEx

Path: /windows/win32/api/sysinfoapi/nf-sysinfoapi-getnativeprocessormaskex

Function

The GetNativeProcessorMaskEx function retrieves the processor mask for the current process on a given processor group.

This function is useful in scenarios where you need to manage or query processor affinity at a granular level, especially on systems with multiple processor groups.

Syntax

BOOL GetNativeProcessorMaskEx( _In_ USHORT nProcessorGroup, _Out_ PPROCESSOR_NUMBER lpProcessornumber, _Out_ PGROUP_AFFINITY lpGroupAffinity );

Parameters

  • USHORT nProcessorGroup

    The processor group for which to retrieve the mask. This value can range from 0 to 63.

  • PPROCESSOR_NUMBER pointer lpProcessornumber

    A pointer to a PROCESSOR_NUMBER structure that receives the processor number.

  • PGROUP_AFFINITY pointer lpGroupAffinity

    A pointer to a GROUP_AFFINITY structure that receives the processor group affinity.

Return Value

TRUE if the function succeeds,
FALSE otherwise. To get extended error information, call GetLastError.

Remarks

This function allows you to obtain the specific processor number and its associated group affinity for a given processor group index. This is crucial for advanced process scheduling and resource management on multi-processor systems with NUMA architecture or where processor groups are utilized.

The PROCESSOR_NUMBER structure identifies a specific processor by its group and number within that group. The GROUP_AFFINITY structure represents the set of logical processors that a thread or process can run on. When used with GetNativeProcessorMaskEx, it specifies the mask for the target processor group.

Ensure that the system supports processor groups before calling this function. You can check this using GetLogicalProcessorInformationEx.

Requirements

Header: sysinfoapi.h (include windows.h)

Library: Use Kernel32.lib

Minimum supported client: Windows 7, Windows Vista with SP1
Minimum supported server: Windows Server 2008 R2, Windows Server 2008 with SP1

DLL: Kernel32.dll

See Also