How can I set the default affinity for any process in Windows?
Solution 1
Process Lasso supports this! It comes with a free and paid version, CPU affinities is always free...
Just fill in a *
in the Name match
field, which will target all processes.
I think you can then add your programs to have another affinity, the order in which you enter the rules might matter. Also, you can tick More strictly enforce default affinities
at the bottom.
Solution 2
If you go into task manager processes and right click on the process you should be able to select the affinity.
To disable a core you can use msconfig. I don't think you can enable it on a per-process basis.
Related videos on Youtube
Comments
-
Nathan Fellman almost 2 years
I want to run some benchmarks on Windows 7. These benchmarks have to do with hyper-threading on a multi-core CPU. For this, I want to ensure that only the benchmarks are running on their own logical processor. Is there any way to tell Windows to not schedule anything on there certain logical processors, unless I allow it explicitly for a process?
Doing this manually in the task manager, one process at a time, is not an option. I want to be able to do this repeatedly (I will be running many benchmarks many times). I know how to programmatically set the affinity for the current running process.
Is there any configuration that can allow me to set the default affinity for all processes?
-
Admin over 12 yearsMight be better off stopping "system things" so they dont get in the way and increasing the priority and setting affinity for the benchmarks themselves, so other fuctions will only be able to use the leftover one. What do you do when the benchmark itself relies heavily ON various functions you park to the side? could effect results? EX: many benches for Disk I/O are using caches even when that is supposedly bypassing them.
-
Admin over 12 yearsThere was an old program for XP that I used for this purpose, not sure if it can be found for download now...tomshardware.com/reviews/bang-dual-processing-buck,815-3.html
-
Admin over 12 yearsI have a copy of "THG task assignment manager" if you would like to try it on W7.
-
-
Nathan Fellman over 12 yearsOK, I should've been clearer. I want to set the affinity of all processes to use only logical processors 0 and 1, and enable only the processes that I want to to use 2 and 3. Doing manually for each process is not an option.
-
Pubby over 12 years@NathanFellman Yeah, I realized that after I posted. Have you tried disabling them with msconfig->system configuration->advanced?
-
Nathan Fellman over 12 yearsno, I don't know how to do that :-)
-
Pubby over 12 years@NathanFellman I saw it from this: en.kioskea.net/faq/616-multicore-cpu-how-to-disable-a-core Never done it so not sure if it will work in your situation.
-
Nathan Fellman over 12 yearsBut will this allow me to assign only certain processes to the "disabled" processors? It seems to me that this will keep all of the processes off of the processor I want to keep clear, including my benchmark.
-
Simon Sheehan over 12 years@NathanFellman I'm actually not entirely sure - perhaps you could test that?
-
Tamara Wijsman over 12 years@NathanFellman:
/NUMPROC=number
sets the number of processors that Windows will run at startup. With this switch, you can force a multiprocessor system to use only the quantity of processors (number) that you specify. This switch can help you troubleshoot performance problems and defective CPUs. — See Support. This does mean that the processors can't be used anymore once you limit them. -
surfasb over 12 yearsI use a similar utility for Folding@home.
-
Jamie Hanrahan over 8 yearsNote that some "system things", like interrupt handling and DPCs, will not be affected. There may also be permiision issues trying to set affinities for system threads and protected system processes.
-
Alexandros almost 6 yearsI managed to do exactly what was asked using this tool. I added a * rule for logical cores 0-3 and a "javaw" rule for 4-7, then used JNA from my Java program to set affinity to cores 4 and 6. Worked like a charm, my 2 threads had the cores all to themselves. Even confirmed memory visibility taking effect using sun.misc.Unsafe store/load fences.