![]() |
|
Introduction An application that is multi-threaded or an application that creates threads may have a contention problem on a multi-processor machine. The threads may actually be running at the same time on different processors. By binding a process to a cpu, no two threads are running at the same time and are not interfering with one another. Your application will run as if on a single-processor machine. Binding on NT You can bind a process to a cpu either from the Task Manager, using Win32
calls or permanently setting the processor affinity for an application executable.
Binding from the Task Manager 1. Select the "Processes" tab in Task Manager.
Binding Using Win32 Calls Use the SetProcessAffinityMask() function to bind a particular application to a cpu. The function is in the kernel32.dll. The first parameter is a handle to a process. Use the GetCurrentProcess to get the handle. The second parameter describes which processors the process should run on. Declare the functions as follows: function ulong GetCurrentProcess() library "kernel32.dll" Ulong lul_process,lul_lpProcessAffinityMask // 0123 – As they appear in Task Manager (CPU 0, CPU 1, CPU 2, CPU 3) CHOOSE CASE ai_processor lul_process = GetCurrentProcess( ) Permanently Setting the Processor Affinity for an Application Executable On Windows NT, Windows 2000 or Windows XP, you can permanently set the
processor affinity for an application executable by imagecfg -a 0xn c:\program files\sybase\Jaguar CTS\bin\jagsrv.exe where 0xn is the affinity mask and maps to a cpu as follows: Binding on Solaris You can bind a process to a cpu at the command line or using a shell script. Binding at the command line 1. Use psrinfo to find the processor id # you want to bind to Binding using a shell script #!/usr/bin/sh
|
|||||||||||