Windows – How to limit a process to a single CPU core

multi-coreprocesswindows

How do you limit a single process program run in a Windows environment to run only on a single CPU on a multi-core machine?

Is it the same between a windowed program and a command line program?

UPDATE:

  • Reason for doing this: benchmarking various programming languages aspects
  • I need something that would work from the very start of the process, therefore @akseli's answer, although great for other cases, doesn't solve my case

Best Answer

If you're running Windows Vista/7 (possibly XP, but not sure) it's really rather simple. You have to be an administrator to get this to work.

  1. Press Ctrl + Shift + Esc to get open Task Manager.
  2. Click on the Processes tab.
  3. Find the process that needs its processor affinity changed.
  4. Right-click on the process.
  5. Click on "Set Affinity".

Here you can select which processor(s) your process will use.

Related Question