• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Permanently setting Processor Affinity in XP?

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Mpegger

Member
Joined
Nov 28, 2001
I have a program that doesn't work right with my HT cpu unless I set it to use only 1 of the 2 visible cpu's. I'd like to set it to use cpu 0 when the program is ran, instead of having to use Task Manager. But I dont see any option for Processor Affinity in the Properties tab for the executable. Anyone know of another way?
 
You can permanently set processor affinity for a non-operating system executable, on both Windows 2000 and Windows NT 4.0, by using the Imagecfg.exe tool from the \support\debug\i386 folder of a Windows NT 4.0 CD-ROM, or the Imagecfg.exe tool from the Windows 2000 Server Resource Kit Supplement One.

NOTE: Do NOT use imagecfg on any kernel operating system files.

To permanently set the processor affinity for your 32-bit executable, open a CMD prompt and type:

imagecfg -a 0xn <Drive:>\Path\yourprogram.exe

where 0xn is the affinity mask. The mask constrains your application to a specific CPU, from 0 - 31, where:

CPU MASK
0 0x1
1 0x2
2 0x4
3 0x8
4 0x10
5 0x20
6 0x40
7 0x80
8 0x100
etc
To set the affinity for "c:\util\Country Codes.exe" to processor 1, type:
imagecfg -a 0x2 "c:\util\Country Codes.exe"

and you will receive the following response:

c:\util\Country Codes.exe contains no configuration information
c:\util\Country Codes.exe contains a Subsystem Version of 4.0
c:\util\Country Codes.exe updated with the following configuration information:
Process Affinity Mask: 00000002
When you launch Country Codes.exe, its' affinity is set to CPU 1.
 
My gawd I forgot about this one. The program in question has long since been fixed to work fine on multi-threaded processors, and unfortunetly, this work around didnt work on it. Would cause immediate crashing of the program upon startup. I've found that not all programs work correctly with this fix, as I had another program not too long ago that I wanted to set affinity with, also did not work when this fix was applied (I remembered the processor affinity setting and Googled it).
 
Back