Lewcid.com
Site-Cube

(this Subject)
#that
(this Time)
#6/20/2006
(this Place)
download/
(this Lewey Geselowitz)

 

Affinity - Tool To Use Only One CPU

Affinity is a small tool which can launch an application and restrict it to one CPU. Some older applications and games (such as the amazing System Shock 2) don�t work properly on multi-processor systems, but if you restrict them to one CPU then they work fine. Some tools exist out there to set the affinity of an application while it is running (Windows Task Manager can do this), however this is a hassle, rather just drop the application that you want to execute onto Affinity and it�s done in a completely non-invasive way. The term �affinity� is the set of CPUs on which Windows lets an application run.

Affinity.exe

Platform: Windows
Usage: Drop an executable on Affinity to launch it on only one CPU

SystemShock2.bat

Platform: Windows
Usage: Put this and Affinity.exe into your System Shock 2 folder, then run SystemShock2.bat. This will solve the multi-CPU / hyperthreading problem in a non-invasive way.
Note: This file merely contains 'Affinity SHOCK2.EXE'

How It Works
This a very simple app, the idea is that processor affinity is inherited by child processes; so Affinity sets it�s own affinity to only the first CPU, and then executes it�s argument, that simple. Here are the two core pieces of code (Win32 API for C); the first sets Affinity to run on only the first CPU, and the second executes the first argument to the app.

SetProcessAffinityMask( GetCurrentProcess(), 1 );
ShellExecute( NULL, NULL, argv[1], NULL, NULL, SW_SHOWNORMAL );

Running System Shock 2
I use Affinity to run System Shock 2 which makes it stable on multi-CPU or hyper-threaded systems. This means I can run the game using a simple script instead of starting it, switching to the Task Manager, setting the affinity and then switching back. Just download Affinity and the script below, put them in your System Shock 2 folder (probably C:/Sshock2/) and then execute the script to start playing. Optionally you can make a shortcut to the script file and use that (which is what I do).