KeSetSystemAffinityThread function

The KeSetSystemAffinityThread routine sets the system affinity of the current thread.


VOID KeSetSystemAffinityThread(
  _In_ KAFFINITY Affinity



A KAFFINITY-typed variable that specifies the new system affinity of the current thread.

Return Value



The implementation of KeSetSystemAffinityThread 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, KeSetSystemAffinityThread assigns the thread to group 0, and uses the affinity mask to specify a set of logical processors in this group on which the thread can run.

If KeSetSystemAffinityThread is called at IRQL <= APC_LEVEL and the call is successful, the new affinity mask takes effect immediately. When the call returns, the calling thread is already running on a processor that is specified in the new affinity mask. If KeSetSystemAffinityThread is called at IRQL = DISPATCH_LEVEL and the call is successful, the pending processor change is deferred until the caller lowers the IRQL below DISPATCH_LEVEL.


Windows version Available in Windows 2000 and later versions of Windows. Use KeSetSystemAffinityThread only on systems before Windows Vista. In Windows Vista and later versions of the Windows operating system, use KeSetSystemAffinityThreadEx instead.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL "<= DISPATCH_LEVEL (see Remarks section)."
DDI compliance rules PowerIrpDDis, HwStorPortProhibitedDDIs

See Also



Send comments about this topic to Microsoft