Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set processor affinity from Batch File for Windows XP?

I've got a dual processor machine and I would like to launch an executable via a batch file on both processors.

For example: (1) Launch Notepad.exe on Processor 1, and (2) Simultaneously, Notepad.exe on Processor 2

Currently, I'm using the following in my batch file, since my executable was "difficult" to launch and needed a return in order to run when launched: echo.|DoStuff.exe

Thus, I would like to launch it and have it run on each processor.

Thanks for any feedback provided.

P.S. I don't think "start" will work for me since I need to send in the return character to the executable as shown above with echo.

P.S.S. This is for a Windows XP solution. Thanks.

like image 998
JustADude Avatar asked May 06 '09 02:05

JustADude


People also ask

How do I check my CPU affinity?

CPU affinity enables binding a process or multiple processes to a specific CPU core in a way that the process(es) will run from that specific core only. When trying to perform performance testing on a host with many cores, it is wise to run multiple instances of a process, each one on different core.


2 Answers

start /affinity 1 notepad.exe

start /affinity 2 notepad.exe

(Windows7 has affinity for the start command, but XP does not. PSexec works though)

like image 121
Rich.Carpenter Avatar answered Sep 28 '22 07:09

Rich.Carpenter


Microsoft's Sysinternal's psexec's -a flag can set processor affinity on Windows XP:

Usage: psexec [\\computer[,computer2[,...] | @file][-u user [-p psswd]][-n s][-l][-s|-e][-x][-i
[session]][-c [-f|-v]][-w directory][-d][-][-a n,n,...] cmd [arguments]
     -a         Separate processors on which the application can run with
                commas where 1 is the lowest numbered CPU. For example,
                to run the application on CPU 2 and CPU 4, enter:
                "-a 2,4"

For example:

psexec -a 2 cmd /c "echo.|DoStuff.exe"
like image 40
Anonymous Avatar answered Sep 28 '22 06:09

Anonymous