Problem solve Get help with specific problems with your technologies, process and projects.

Permanent processor affinity

How to link a particular third-party program with a particular processor.

Permanent processor affinity
Serdar Yegulalp

"Processor affinity" is a term used when running applications on a system with more than one processor. A common way to distribute the load through a system with multiple processors is to associate a particular app with a particular processor. That way, apps that have typically high demands -- such as SQL Server -- stay with their own processor and don't steal processing power from other applications, which may also have their own affinities. This way you can insure that applications that are launched without direct user intervention can distribute themselves evenly across processors.

Some programs can do this internally -- associate themselves with a particular processor -- but such applications are few and far between. If you want to do this yourself with an app that doesn't normally support it, you'll need to use a tool from the Windows 2000 Server Resource Kit (Supplement #1). You can also find this tool in the SUPPORT folder of the Windows NT/2K Server CD-ROM.

The tool in question is named IMAGECFG.EXE -- Image Config, so named because Microsoft refers to application binaries in Windows as the "image" of an application. Don't use IMAGECFG on any binaries that come bundled with the OS, just third-party applications.

To set processor affinity for an app, you'll need to run IMAGECFG from the command line with the following parameters.

imagecfg -a 0xn <D:>Pathprogram.exe

The "0xn" is a hex code that sets which processor to give the program affinity to. For processor 0, it's 0x1; for processor 1, it's 0x2. The numbers go up to 32 processors, but the progression of the mask is peculiar: 0x1, 0x2, 0x4, 0x8, then 0x10, 0x20, 0x40, 0x80, 0x100, 0x200, and so on.

Once you do this, the binary for the program in question will be changed permanently, so it's a good idea to make a backup copy of the binary in question before playing with this. Also, you cannot use IMAGECFG on .DLLs.

Serdar Yegulalp is the editor of the Windows 2000 Power Users Newsletter.

Dig Deeper on Windows systems and network management