Is there any way to set the affinity for all running processes in Windows 7?
I want to run some hyperthreading benchmarks, and I want to ensure that they're running alone on a certain core. I'm running them with a wrapper, and I want to do something like this (in pseudocode):
foreach process in <list of all processes>
set affinity to all cores but core x
set affinity of the current process to core x
run benchmark 0 on core x thread 0
run benchmark 1 on core x thread 1
Now, I think that I know how to set the affinity of the current process and its children, but how can I:
- iterate over all processes?
- set the affinity of other processes?
SeDebugPrivilege
(requires that your program runs as admin).