Hi
What is affinity mask (SetThreadAffinityMask) for first CPU is 0 or 1?
Thanks
Hi
What is affinity mask (SetThreadAffinityMask) for first CPU is 0 or 1?
Thanks
You can see this function from MS (D3D11 samples) :
void CDXUTTimer::LimitThreadAffinityToCurrentProc()
{
HANDLE hCurrentProcess = GetCurrentProcess();
// Get the processor affinity mask for this process
DWORD_PTR dwProcessAffinityMask = 0;
DWORD_PTR dwSystemAffinityMask = 0;
if( GetProcessAffinityMask( hCurrentProcess, &dwProcessAffinityMask, &dwSystemAffinityMask ) != 0 &&
dwProcessAffinityMask )
{
// Find the lowest processor that our process is allows to run against
DWORD_PTR dwAffinityMask = ( dwProcessAffinityMask & ( ( ~dwProcessAffinityMask ) + 1 ) );
// Set this as the processor that our thread must always run against
// This must be a subset of the process affinity mask
HANDLE hCurrentThread = GetCurrentThread();
if( INVALID_HANDLE_VALUE != hCurrentThread )
{
SetThreadAffinityMask( hCurrentThread, dwAffinityMask );
CloseHandle( hCurrentThread );
}
}
CloseHandle( hCurrentProcess );
}
10 people are following this question.