Welcome to the Procaff page! Procaff was written for Windows NT4/Windows 2000 and its purpose is to start a process (an application) on a machine with more than one processor (CPU) on one dedicated processor or on a subset of the available processors. Its name stands for "Processor Affinity" which is the one property, ProcAff changes for the process it creates or changes. Since version 22.214.171.124 , ProcAff is also capable of changing the processor affinity of already running processes. Version 126.96.36.199 adds a native x64 binary so you can set the processor affinity for a maximum of 64 logical CPUs.
|Downloads thus far:|| 6439
What is a Processor Affinity?
The processor affinity is simply a number that every process is associated with. It serves as a bit array that determines on which CPUs in a system the threads of a particular process are allowed to run. For instance a processor affinity of 2 means that the process can only run on CPU 1, because only the bit at index 1 is set (if the processor affinity is regarded as a bit array with indexing starting at the rightmost bit with zero). A processor affinity of 1 means, that the process, or better yet, the threads of that process, can only run on CPU 0. A processor affinity of 3 means that the process may run on both CPUs 0 and 1. A processor affinity of 0 means that there is no CPU that this process may run on, and is therefore not possible.
The processor affinity is normally inherited from the parent process that starts a particular process, but it can also be changed at runtime from another process. Both these things are implemented in procaff.
ProcAff's command line interface has changed with version 188.8.131.52. The old command line interface is still working, but is deprecated. In other words: Don't use the old-style command line interface anymore! Therefore, only the new command line interface is documented here:
Procaff simply interprets the first argument it gets as an option, whether to start a process synchronuosly or asynchronuosly or whether an already existing process should be modified. There are three different options: /wait, /run and /set, and one of them must be specified as the first command line parameter.
With /wait, a new process will be started synchronuosly, i.e. procaff will wait until the new process terminates and will then issue the exit code of the new process in its console. With /run, the new process will start asynchronuosly, i.e. procaff will not wait for the new process to terminate and thus will not be able to determine the newly started processes' exit code (coz' it simply doesn't bother about that processes termination). For both /wait and /run, the second command line parameter is the processor affinity of the new process. The last parameter is the command line of the new process.
With /set as the first command line parameter, the second command line parameter is again the processor affinity of the process, but this time the processor affinity of an already existing process that you have to specify with the third command line parameter. The third parameter is to be specified as the process id of the existing process or the name of the process. Resolving the process name works without any additional measures on Windows 2000. For this to work on NT4 as well, you have to install the Process Status Helper API DLL (psapi.dll) which you can dowload here in version 4.0.1371.1 as of 1 Jun 2001. Since this is a redistributable file for NT4 that comes with the Platform SDK, I am allowed to distribute it. Click here for installation instructions for this DLL.
Just in case you are now confused about the command line interface of procaff, here are a few examples:
In order to start notepad.exe on CPU 1 synchronously you simply specify:
procaff /wait 2 notepad.exe
In order to start notepad.exe on CPU 0 synchronously and passing notepad a command line parameter you simply specify something like that:
procaff /wait 1 notepad.exe c:\autoexec.bat
If the application you want to start resides in a path or file name with embedded spaces, double-quote it, like this:
procaff /wait 3 "c:\my documents\foo.exe" -a -b -c
You can also specify valid environment variables, procaff will try to map them to their respective values:
procaff /wait 2 %systemroot%\notepad.exe
In order to start a process asynchronuosly, just replace in the samples above /wait with /run.
If you want to modify a processes' processor affinity, look up its process id in task manager and specify it as the third command line parameter. As the first command line parameter you specify /set.
As an example, if you want to set the process affinity of the process with process ID 1232 so that it runs only on CPU 1, specify the following:
procaff /set 2 1232
If you know that particular processes' name, just supply the name (with or without extension) instead of the process ID:
procaff /set 1 netscape
Note that for this feature to work on NT4 you have to properly install psapi.dll (see above). Note also, that procaff will only change the processor affinity in this case if there is only one process with this name. If there is more than one process with the same name running, procaff will refuse to change any of the processes' processor affinity, if only the name is specified. In this case you definitely have to supply the process ID.
Unfortunately, it is not possible to return the exit code of the called program to the caller, because under certain conditions, procaff can fail, too, If procaff fails, it issues the reason for the failure on stdout and returns with an exit code of 255. If everything works okay, the exit code is 0. If a synchronuosly spawned application terminates, procaff will issue the called processes exit code on stdout, like this:
Process c:\temp\foo.exe terminated with exit code 1
First of all, check whether you really need psapi.dll. If you are running Windows 2000 or higher, there is no need to download it, because an appropriate version already comes with the operating system. If you are running procaff on NT4 and procaff complains that it cannot load psapi.dll, download psapi.dll, for instance from this location. Microsoft recommends installing it in the %windir%\System directory (strangely enough, on Windows 2000 it is installed in the %windir%\system32 directory). I simply copied it into the very same directory where the binary of procaff resides and it worked. Maybe this works for you as well. If you really want to copy it into the %windir%\system or windir%\system32 directory, please check that you don't overwrite a newer version that is already there. If you don't know how to check whether an already installed version is newer, it is probably better that you simply don't overwrite an already existing version.
...well, simply because I am having a dual processor machine at home (and I also had one at work before I quit to study again) for quite some time now and a lot of multithreaded applications behave badly on such machines, either they deadlock or they crash for some reason. Note that this is not because of the operating system, no, it is the developers of these apps who are to blame. Lots of multithreaded apps are simply almost never (obviously) tested on dual or quad CPU machines, and the only way to use them anyway, is to force them to run on a single dedicated CPU with a tool like procaff.
Uuh, ooh,... nothing, no, really! Anybody can do that, everything is pretty well documented.