Set Affinity using command prompt?

Z

zachlr1

Is there a way to set a process affinity using command prompt? I
would like to make a .bat for setting all unimportant processes to
core 0, and all my games to both. And then to set all processes to
both cores when I am finished playing.
Also is this available on XP? My friend is looking to do the same
thing on XP.

Thanks,
Zach
 
Z

zachlr1

Hi Zach:

A quick Googlehttp://www.google.com/search?hl=en&q=vista+cpu+affinity

turned up

http://www.howtogeek.com/howto/windows-vista/start-an-application-ass...

which sounds like it might be what you want?



What I get from that is that you use that command to start a process
in a given affinity. Correct? However, I am looking to change the
affinity of a given process that is already running, and cannot be
restarted. This way, before I start a game, I can run the .bat file
to change all of the given processes to affinity on core 0, and games
on core 1. Then change back to normal once I am finished. I know
that you can do this with task manager and right clicking each
individual process, but this is very time consuming and inconvenient.
I say command prompt because I thought of automating it with a .bat
file, but if you know of any other (free) programs that deal with
affinity, please let me know.
 
A

Andrew McLaren

What I get from that is that you use that command to start a process
in a given affinity. Correct? However, I am looking to change the
affinity of a given process that is already running, and cannot be

You can change the affinity using the GUI, ie Task Manager. Select the
Processes tab, highlight the process you want, right-click, and choose
"Affinity" from the context menu. This lets you change the affinity of the
running process.

There is no command-line tool to perform the same operation. You might be
able to do it with WMI Scripting.

Affinity is widely misunderstood. If your goal is to get better performance
for the game, you're probably wasting your time. Contrary to the simplistic
view, setting affinity does not generally improve performance. The unit of
scheduling in NT (including, here, Vista) is the Thread, not the Process. By
hard-binding a Process to a single CPU, you're actually lowering the chances
that the process's Threads will be scheduled to run. Besides, many or most
games are single-threaded anyway (they will only run on a single CPU, even
in multi-proc machines).

A couple of years ago I did a detailed performance analysis of a web
application (online banking) which a customer wanted to "optimise" it by
setting the affinity. After a week with Perfmon, the conclusion was that
there was no performance benefit whatever, and in fact a performance drop in
several scenarios, when a process is bound to a single CPU. The NT Scheduler
is pretty smart, and can be relied on to make good scheduling decisions in
most cases. If you have a performance bottleneck, it won't be because your
game is being starved for CPU. Or if it is, just close down the other
running processes before you start the game - that will be the more relaible
and effective way to get more CPU.

The main benefit of setting affinity is to provide comptibility for apps
which don't run well on multi-proc machines; you can fool them into thinking
they are running on a single proc machine.

You could try increasing the Priority of the game, so that it gets scheduled
to run at a higher probability - but again, the nett effect of this is often
less than obvious, and in most interactive applications, doesn't provide a
tangible benefit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top