Set CPU Affinity prior to app launch?

Page 2 - Seeking answers? Join the Tom's Hardware community: where nearly two million members share solutions and discuss the latest tech.
Status
Not open for further replies.
I know this is an old thread, but here's the easy answer that didn't come up. WinXP (and also Vista, I believe) has a utility included called start. This utility can be used to run a program with a specified cpu affinity. the command would look like this:

start /affinity xx myprogram.exe

Use the actual name of the program you want to run, of course, and substitute xx for a hex number representing the affinity you want as follows:

01 - 1st CPU
02 - 2nd CPU
03 - 1st and 2nd CPU
04 - 3rd CPU
05 - 1st and 3rd CPU
...
etc
 
please let me know more, im trying to run silent hill 2 on 1 cpu but cant set it from task manager as i get an error. where is this utility in vista? goto run? thanks. Ben
 
Found this while reading for issues like this.

For windows 7, not sure with other os.

Create shortcut of app.
Right click on shortcut.
Properties.
Target line:C:\Windows\System32\cmd.exe /C start /affinity 1 C:\(ProgramFolder)\(program).exe

(1 can be changed depending on the affinity you wish to set)
 
well i use win7 and that doesnt work for me,
What i am trying to do is make a program use both cores for smoother sailing

C:\Windows\System32\cmd.exe /C start /affinity 0 1 C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe
(modified command line to set sam using the two cores)

C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe
(is the original command line)
 
You can do this by modifiying a programs launch options. Theres also a few third party apps that do this (Forcecore, etc).

Problem is, don't try to be smarter then the Windows scheduler. Forcing the issue will probably cause a performance loss in the long run.
 

Orion, your command line should read:

C:\Windows\System32\cmd.exe /C start "" /affinity 3 "C:\Program Files\SpacialAudio\SAMBC\SAMBC.exe"

I've added the quotes for clarity. I'm not sure if it likes spaces in paths. I've added the first set of quotes because Start will annoyingly use the first set of quoted text as the title.

The affinity should be a single hexadecimal number, not a list of CPU numbers:
1 = use CPU 0
2 = use CPU 1
3 = use CPU 1 and 0
4 = use CPU 2
...
F = use CPU 3, 2, 1 and 0


EDIT: I forgot to say, all applications use all CPUs by default. It may by that SAMBC has not been designed to take advantage of multi-core processors, in which case there's nothing you can do to force it to run on both. It will have access to both, but will only use as many as it wants to.
 
Would there be a way to run EVERYTHING on core 0 unless specified otherwise? For example on my brother's laptop, it would be convenient to run everything on core 0, maybe winsystem on core 1, and then if he's dual-boxing World of Warcraft he can have a wow.exe on core3 and a wow.exe on core4

Any ideas?
 
I doubt it, and frankly I'd be surprised if that was in any way a good idea. I may be wrong, but that just sounds like a control-freak idea (which I'm good at too) that's going to cause more problems than worth.

Many programs now have multi-core support and will run across all four cores. By limiting a process to one core, you're essentially denying it access to three-quarters of your processing power. Processes that aren't busy won't use a significant amount of processor power anyway.

The only way I can think to achieve your idea is to find a way to force everything to run on core 0. They you can set up individual applications to use a particular core using the suggestions in the previous posts. The trouble is, I don't know of anywhere in Windows where you can set default affinity settings.
 
How about linux? I'm playing with various distros now in VMware, deciding which one to dual boot with 7 when I install it.
 
And the only reason why I ask that is if my system ran fine on a single athlon 64 3000+ (2.6-2.8ghz i think?) playing video games, then why shouldn't I be able to run everything BUT my games on 1 of my 3.0ghz cores? I'm probably not understanding computing logic here, but in my mind if I have 4 3.0ghz cores why shouldn't I be able to run everything the way I used to on my old computer on one core, and then run games on a second, and virtual machines on 3rd and 4th
 
Status
Not open for further replies.