Skip to content

Latest commit

 

History

History
117 lines (79 loc) · 5.3 KB

nf-winbase-getprocessaffinitymask.md

File metadata and controls

117 lines (79 loc) · 5.3 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:winbase.GetProcessAffinityMask
GetProcessAffinityMask function (winbase.h)
Retrieves the process affinity mask for the specified process and the system affinity mask for the system.
GetProcessAffinityMask
GetProcessAffinityMask function
_win32_getprocessaffinitymask
base.getprocessaffinitymask
winbase/GetProcessAffinityMask
base\getprocessaffinitymask.htm
backup
f50ca86e-fa81-4ed9-ae6c-63a4e7f2a53f
12/05/2018
GetProcessAffinityMask, GetProcessAffinityMask function, _win32_getprocessaffinitymask, base.getprocessaffinitymask, winbase/GetProcessAffinityMask
winbase.h
Windows.h
Windows
Windows XP [desktop apps \| UWP apps]
Windows Server 2003 [desktop apps \| UWP apps]
Kernel32.lib
Kernel32.dll
Windows
19H1
GetProcessAffinityMask
winbase/GetProcessAffinityMask
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-ProcessTopology-Obsolete-L1-1-0.dll
API-MS-Win-Core-ProcessTopology-Obsolete-L1-1-1.dll
API-MS-Win-DownLevel-Kernel32-L2-1-0.dll
Kernel32Legacy.dll
GetProcessAffinityMask

GetProcessAffinityMask function

-description

Retrieves the process affinity mask for the specified process and the system affinity mask for the system.

-parameters

-param hProcess [in]

A handle to the process whose affinity mask is desired.

This handle must have the PROCESS_QUERY_INFORMATION or PROCESS_QUERY_LIMITED_INFORMATION access right. For more information, see Process Security and Access Rights.

Windows Server 2003 and Windows XP:  The handle must have the PROCESS_QUERY_INFORMATION access right.

-param lpProcessAffinityMask [out]

A pointer to a variable that receives the affinity mask for the specified process.

-param lpSystemAffinityMask [out]

A pointer to a variable that receives the affinity mask for the system.

-returns

If the function succeeds, the return value is nonzero and the function sets the variables pointed to by lpProcessAffinityMask and lpSystemAffinityMask to the appropriate affinity masks.

On a system with more than 64 processors, if the threads of the calling process are in a single processor group, the function sets the variables pointed to by lpProcessAffinityMask and lpSystemAffinityMask to the process affinity mask and the processor mask of active logical processors for that group. If the calling process contains threads in multiple groups, the function returns zero for both affinity masks.

If the function fails, the return value is zero, and the values of the variables pointed to by lpProcessAffinityMask and lpSystemAffinityMask are undefined. To get extended error information, call GetLastError.

-remarks

A process affinity mask is a bit vector in which each bit represents the processors that a process is allowed to run on. A system affinity mask is a bit vector in which each bit represents the processors that are configured into a system.

A process affinity mask is a subset of the system affinity mask. A process is only allowed to run on the processors configured into a system. Therefore, the process affinity mask cannot specify a 1 bit for a processor when the system affinity mask specifies a 0 bit for that processor.

Starting with Windows 11 and Windows Server 2022, on a system with more than 64 processors, process and thread affinities span all processors in the system, across all processor groups, by default. The GetProcessAffinityMask function sets the lpProcessAffinityMask and lpSystemAffinityMask to the process and system processor masks over the process' primary group. If the process had explicitly set the affinity of one or more of its threads outside of the process' primary group, the function returns zero for both affinity masks. If, however, hHandle specifies a handle to the current process, the function always uses the calling thread's primary group (which by default is the same as the process' primary group) in order to set the lpProcessAffinityMask and lpSystemAffinityMask.

-see-also

Multiple Processors

Process and Thread Functions

Processes

Processor Groups

SetProcessAffinityMask

SetThreadAffinityMask