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?

  • 1
    Might 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.
    – Psycogeek
    Oct 23 '11 at 13:48
  • There 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
    – Moab
    Oct 23 '11 at 15:29
  • I have a copy of "THG task assignment manager" if you would like to try it on W7.
    – Moab
    Oct 23 '11 at 15:34

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.

enter image description here

  • I use a similar utility for Folding@home.
    – surfasb
    Oct 23 '11 at 18:25
  • Note 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. Feb 3 '16 at 18:48
  • I 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.
    – Alexandros
    Sep 15 '18 at 11:15

If you go into task manager processes and right click on the process you should be able to select the affinity.

enter image description here

To disable a core you can use msconfig. I don't think you can enable it on a per-process basis.

  • OK, 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. Oct 23 '11 at 12:12
  • @NathanFellman Yeah, I realized that after I posted. Have you tried disabling them with msconfig->system configuration->advanced?
    – Pubby
    Oct 23 '11 at 12:14
  • no, I don't know how to do that :-) Oct 23 '11 at 12:15
  • @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.
    – Pubby
    Oct 23 '11 at 12:16
  1. Open your start menu
  2. type msconfig, and hit enter
  3. Go to the tab marked as boot
  4. Highlight the OS of your choice, and hit advanced options.
  5. Check number of processors, and use however many you want.

This causes windows (and everything else) to see and use only the specified number of processors. So it effectively completely disables the rest. It will (and can) never use more than the number of available cores).

enter image description here

  • But 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. Oct 23 '11 at 13:15
  • @NathanFellman I'm actually not entirely sure - perhaps you could test that? Oct 23 '11 at 13:30
  • 1
    @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. Oct 23 '11 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.