tags:

views:

183

answers:

2

Is it possible to programmatically either via the win32API (python) or via a command line option set the processor affinity for a process?

A: 

In C/C++ you can use SetThreadIdealProcessor(). I have no idea if this is accessible in python.

DWORD processorId = 0;
SetThreadIdealProcessor(GetCurrentThread(),processorId);
SoapBox
+3  A: 

Given a process handle, you can call the SetProcessAffinityMask Win32 API function to set the processor affinity for another process. Note that all the usual security restrictions are in effect, that is, you will probably only be able to change the process affinity for a process you own.

Greg Hewgill