how to set processor affinity automatically

Status
Not open for further replies.

htoon

Distinguished
Mar 22, 2006
33
0
18,530
hello

I have a dual-processor system. I would like to assign one of the processors to a specific program automatically so that i do not need to do manually. Can anyone know how to do. Please help me out.

Take care.
 
To be honest, I don't think it is possible on Windows XP. If a program tried, it would probably not know what to put on what processor and not know how to handle a third window. Is it really that hard to do it manually? However, I have heard that some versions of Linux will do it automatically. PM linux_0 for more information on that.
 
Thank you for the reply. it is easy to set processor affinity manually.

But I want to assign automatically so that i do not need to adjust it manually. is there anyone know how to do it. I am using winxp professional. Is it possible.

Thank you all.
 
Depending on the software there may be a registry entry you can adjust




Thank you for your reply. Do you know how to tweak the registry.
 
I've tried this utility for SimCity 4, I set up the profile for the game, and set the affinity to one cpu. Task assign is running then I start the game, I alt tab to windows task manager and check the affinity of SimCity4 in task manager and it's still showing that it's assigned to 2 cpus.

Does it always do that even if taskassign is forcing it to run on one cpu? Or does task assign not actually work properly with some games. For example I can't even get Taskassign to recognize when SC4 is running, it's not one of the listed running programs even.
 


AutoIt has all this stuff builtin now and is quite easy to use. You just write BASIC like scripts and run them directly through AutoIt shell integrated interpreter or compile them to .exe's. It is a very mature piece of free software:
http://www.autoitscript.com/autoit3/

PM me if you need any help sorting out your own solution!! :hello:

Bob


Here is a sample script I wrote for assigning x264 worker encoding processes:
(it just sleeps in the background and with 1 x264 worker it assigns the process both cores, with 2 x264 workers it assigns one process to core 1 and the other process to core 2)

I am afraid the _WinAPI_SetProcessAffinityMask needs a process handle and not a PID (process ID number) hence the use of the _WinAPI_OpenProcess call (converts a PID to a handle)!!


[fixed]#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.10.0
Author: Robert Walker

Script Function:
Multicore auto-task assigner

#ce ----------------------------------------------------------------------------

#Include <WinAPI.au3>

Const $c_x264_executable="x264.exe"
Global $a_x264_PID_list, $h_x264

While 1
Sleep(10000)

$a_x264_PID_list = ProcessList ($c_x264_executable)

Switch $a_x264_PID_list[0][0]
Case 1
$h_x264 = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION+$PROCESS_SET_INFORMATION, False, $a_x264_PID_list[1][1])
_WinAPI_SetProcessAffinityMask($h_x264, 0x03)
Case 2
$h_x264 = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION+$PROCESS_SET_INFORMATION, False, $a_x264_PID_list[1][1])
_WinAPI_SetProcessAffinityMask($h_x264, 0x01)
$h_x264 = _WinAPI_OpenProcess($PROCESS_QUERY_INFORMATION+$PROCESS_SET_INFORMATION, False, $a_x264_PID_list[2][1])
_WinAPI_SetProcessAffinityMask($h_x264, 0x02)
EndSwitch
WEnd

Exit
[/fixed]
 

Same here, but with Stanford's Folding@Home and with the BOINC client.

Would appreciate an answer to this, because right now it looks as though that THC thing doesn't do jack.
 
Same here, but with Stanford's Folding@Home and with the BOINC client.

Would appreciate an answer to this, because right now it looks as though that THC thing doesn't do jack.

OK. I'll put a GUI front-end on my script and repost it.

Bob
 
Status
Not open for further replies.