Windows machines with more than a single processor are known as Symmetrical
Multi-Processing (SMP) systems. Setting the affinity of a task (a process or
thread) is done by a queue scheduling algorithm by modifying the task's
affinity tag. This affinity tag indicates the preferred processor which
normally will hold cached information from previous executions.
Some applications do not perform well in a SMP system and may not even run
at all. In order to solve this issue, you can contact the vendor for a
solution such as updated software or patches, if the vendor does not offer
a solution, and you must use this application, you can use one of the
following solutions:
1) Modify the BOOT.INI File
2) Modify the EXECUTABLE File
Modifying the BOOT.INI file will turn the entire system into a single
processor machine, making the system the same as though only one processor
was installed.
Modifying the EXECUTABLE file will set the affinity on that particular file
to run on only a single processor, this is the preferred method. If after
modifying the EXE the program still has problems, you can always choose to
restore the backed up EXE and use the BOOT.INI file method. The method of
modifying the EXE is done with a Microsoft utility called imagecfg.exe, this
tool will modify the EXE file's headers in order to set the affinity
permanently.
If the application does not crash immediately when opened, you can find the
process in the Task Manager, right-click it, and set the affinity there in
order to determine if simply setting the affinity of the process will solve
the problem, if this works, you know that using the imagecfg.exe method to
set the affinity will most likely work.
As dual and quad core systems become more popular, eventually you will see
an issue where a company is upgrading their hardware but still relies on a
software package that must go thru extensive migration in order to be
updated, a process which the customer may not want to pursue simply to run
all the cores in available in this new hardware.
BOOT.INI
You can disable a Multi Processor machine from using more than a single
processor by adding the "/numproc=1" switch to the BOOT.INI file. The best
way to do this is to copy the existing menu option and add a secondary option
with this switch added.
C:\BOOT.INI Example ( ... = code removed)
[boot loader]
timeout=04
default=multi(0)disk(0)rdisk(0)partition(2)\WINDOWS
[operating systems]
multi(0)...\WINDOWS="XP" /noexecute=optin /fastdetect
multi(0)...\WINDOWS="XP (Single Core)" /noexecute=optin /fastdetect /numproc=1
Microsoft ImageCFG Utility (imagecfg.exe)
imagecfg.exe
imagecfg.exe
http://www.robpol86.com/Files/imagecfg.exe
Tool to permanently set the processor affinity for a 32-bit executable.
Included on the Windows 2000 Server Supplement One Resource Kit CD-ROM.
NOTE:
o Do NOT use imagecfg on any kernel operating system files.
o You need to create a backup of the .exe file before you use it, because it
modifies the file directly and writes new header information.
See Also Interrupt-Affinity Filter Tool:
http://support.microsoft.com/kb/252867/
IntFilt is also included in the Windows Server 2003 Resource Kit Tools (works with XP)
Imagecfg is a nifty little program which automatically sets an executable to run on a
single core at launch. When you find a program which needs to be run on one core, all
you have to do is go into Start > Run... and type:
imagecfg -a 0x1 "x:\path\to\application.exe"
(the 1 in 0x1 may be replaced by a 2 if you want that specific game/program to run on
the second core... good for organisation I guess. eg you could have games run on core 2
while everything else runs on core 1) or if that doesnt work you can try:
imagecfg -u "x:\path\to\application.exe"
Configuration
Copy imagecfg.exe to %systemroot%\system32 and %systemroot%\system32\dllcache.
Doing so will make imagecfg a system command.
This tool only works on NT based operating systems (Windows NT, 2000 Family, XP Family,
2003 Family, Longhorn/Vista). It will work on Multiprocessor machines and Uniprocessor
machines with HyperThreading Technology and multicore processors.
I was unable to find any documentation for this tool on Microsoft's website.
To use this tool to set affinity masks for an executable, type the following command
in a command prompt window or run dialog:
imagecfg -a 0x1 c:\path\to\file.exe
If the above didnt work, try typing the following:
imagecfg -u c:\path\to\file.exe
imagecfg -a 0x1 c:\path\to\file.exe
0x1 = CPU0 (first logical/physical CPU)
0x2 = CPU1 (second CPU)
0x3 = CPU2 (third CPU)
etc...
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 etc...
C:\>imagecfg /?
usage: IMAGECFG [switches] image-names...
[-?] display this message
[-s path to symbol files]
[-v MajorVersion.MinorVersion]
[-w Win32 GetVersion return value in hex]
[-a Process Affinity mask value in hex]
[-u Marks image as uniprocessor only]
[-r run with restricted working set]
[-b BuildNumber]
[-g bitsToClear bitsToSet]
[-o default critical section timeout
[-d decommit thresholds]
[-m maximum allocation size]
[-t VirtualAlloc threshold]
[-p process heap flags]
imagecfg -a 0x2 "C:\Program Files\Silkroad\Silkroad.exe"
imagecfg -a 0x2 "C:\Program Files\Silkroad\sro_client.exe"