34 HANDLE hProcess = GetCurrentProcess();
40 if (GetProcessAffinityMask(hProcess, &appAff, &sysAff))
43 ULONG_PTR currentAffinity = affinity & appAff;
46 TC_LOG_ERROR(logChannel,
"Processors marked in UseProcessors bitmask (hex) {:x} are not accessible. Accessible processors bitmask (hex): {:x}", affinity, appAff);
47 else if (SetProcessAffinityMask(hProcess, currentAffinity))
48 TC_LOG_INFO(logChannel,
"Using processors (bitmask, hex): {:x}", currentAffinity);
50 TC_LOG_ERROR(logChannel,
"Can't set used processors (hex): {:x}", currentAffinity);
56 if (SetPriorityClass(hProcess, HIGH_PRIORITY_CLASS))
57 TC_LOG_INFO(logChannel,
"Process priority class set to HIGH");
59 TC_LOG_ERROR(logChannel,
"Can't set process priority class.");
62#elif defined(__linux__)
69 for (
unsigned int i = 0; i <
sizeof(affinity) * 8; ++i)
70 if (affinity & (1 << i))
73 if (sched_setaffinity(0,
sizeof(mask), &mask))
74 TC_LOG_ERROR(logChannel,
"Can't set used processors (hex): {:x}, error: {}", affinity, strerror(errno));
78 sched_getaffinity(0,
sizeof(mask), &mask);
79 TC_LOG_INFO(logChannel,
"Using processors (bitmask, hex): {:x}", *(__cpu_mask*)(&mask));
85 if (setpriority(PRIO_PROCESS, 0, PROCESS_HIGH_PRIORITY))
86 TC_LOG_ERROR(logChannel,
"Can't set process priority class, error: {}", strerror(errno));
88 TC_LOG_INFO(logChannel,
"Process priority class set to {}", getpriority(PRIO_PROCESS, 0));