Reputation: 57
I want to set process to use all processors. I tried
SetProcessAffinityMask(GetCurrentProcess(), 0);
but it doesn't set to all processors.
Upvotes: 0
Views: 1062
Reputation: 32717
If you read the Microsoft documentation for SetProcessAffinityMask you'll see that you need to specify a 1
bit to enable running on that processor. The call you're making would not allow your process to run on any CPU, so this is probably being rejected. Check the return value of your SetProcessAffinityMask
call and then call GetLastError
if necessary to find out why.
A new process is set to run on all CPUs so you shouldn't need to call this function to specify that, unless your process was spawned by another one that wants to restrict this for reasons of its own.
There are also considerations when running on a system with more than 64 CPUs.
Upvotes: 2