diff --git a/Source/Threading/Threads/AuOSThread.cpp b/Source/Threading/Threads/AuOSThread.cpp index 315dde59..edf0f1ee 100644 --- a/Source/Threading/Threads/AuOSThread.cpp +++ b/Source/Threading/Threads/AuOSThread.cpp @@ -1032,7 +1032,22 @@ namespace Aurora::Threading::Threads } } - SetThreadAffinityMask(this->handle_, mask.lower); + if (mask.CpuBitCount() <= 32) + { + DWORD_PTR uProcMask {}; + DWORD_PTR uSysMask {}; + AuUInt32 uProcmask { mask.lower }; + + if (::GetProcessAffinityMask(GetCurrentProcess(), &uProcMask, &uSysMask)) + { + uProcmask &= uProcMask; + } + + if (::SetThreadAffinityMask(this->handle_, uProcmask)) + { + return; + } + } #endif SysPushErrorUnavailableError("Couldn't set thread affinity");