ProcessGroupAffinity

The ProcessGroupAffinity function sets the processor affinity mask for a process in a specified process group.

BOOL ProcessGroupAffinity(
  HANDLE hProcess,
  USHORT Group,
  PULONGLONG GroupAffinity
);

Parameters

Parameter Description
hProcess A handle to the process whose processor affinity mask is to be set.
Group The process group for which to set the affinity.
GroupAffinity A pointer to a GROUP_AFFINITY structure that specifies the processor affinity mask for the specified process group.

Return value

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Processor affinity determines which processors on a multiprocessor system a thread can run on. By default, a process inherits the affinity mask of the thread that created it. You can use the ProcessGroupAffinity function to modify this affinity.

This function is particularly useful in systems with NUMA (Non-Uniform Memory Access) architectures where processes may need to be explicitly assigned to specific processor groups for optimal performance.

The GROUP_AFFINITY structure contains information about the group number and the affinity mask within that group. The affinity mask is a bitmask where each bit corresponds to a logical processor.

Requirements

Requirements Description
Minimum supported client Windows 7
Minimum supported server Windows Server 2008 R2
Header processthreadsapi.h
Library Kernel32.lib
DLL Kernel32.dll