arottweiler (Banned) Sep 28, 2024 @ 10:55am
Automating CPU Affinity
I have a game that only uses core 0 by default leaving cores 1,2 and 3 redundant and activating the cores via Task Manager works but I'm trying to set a shortcut to do it.

The system has four cores - 0, 1, 2, & 3 and after a lot of searching online I think the hex code for that is F0:

%ComSpec% /C Start /High /affinity F0 Stalker-COP.exe

The first time I tried this in the target box of the shortcut it worked and the game utilised all four cores without having to open Task Manager but when I closed the game and tried again using the same shortcut it went back to only using core 0 so I'm confused. Is that the correct hexadecimal value to utilise cores 0, 1, 2 and 3?
< >
Showing 1-13 of 13 comments
Bad 💀 Motha Sep 28, 2024 @ 4:01pm 
Process Lasso
https://bitsum.com
arottweiler (Banned) Sep 28, 2024 @ 5:42pm 
Originally posted by Bad 💀 Motha:
Process Lasso
https://bitsum.com

Thanks but that seems overkill when a shortcut with a modified target worked once so F0 seems to be the correct hex value for utilising cores 0,1,2,3 on a system that only has those four core but I can't work out why it doesn't work every time.
r.linder Sep 28, 2024 @ 5:52pm 
Process Lasso simplifies the whole process
_I_ Sep 28, 2024 @ 5:55pm 
its binary to decimal/hex conversion that needs to be done

each binary bit is position of core number in reverse, 0 = off, 1 = on

00000001 = 1
00000010 = 2
00000100 = 4
00001000 = 8
00010000 = 16
00100000 = 32
01000000 = 64
10000000 = 128

and so on

add them up to assign specific cores

cores 0+1+2+3 = 00001111 = 15 = or in hex = 0xF
Bad 💀 Motha Sep 28, 2024 @ 6:18pm 
If it's just one or two ganes that do tbat, just load up the game and once it reached main menu, alt+tab over to Task Manager and change the affinity what's the big deal
arottweiler (Banned) Sep 28, 2024 @ 6:36pm 
Originally posted by Bad 💀 Motha:
If it's just one or two ganes that do tbat, just load up the game and once it reached main menu, alt+tab over to Task Manager and change the affinity what's the big deal

Using Task Manager is the manual way and I'm trying to work out a way to automate it which I know is possible I just need to confirm the syntax and hex values. I launch and quit the game a lot while I'm modding the lua scripting so automating is preferable and more convenient than alt+tab and I avoid minimising games as much as possible. Using software would be overkill when I know I can find a solution eventually without it.
Piotrex43 Sep 28, 2024 @ 6:58pm 
Originally posted by arottweiler:
Originally posted by Bad 💀 Motha:
If it's just one or two ganes that do tbat, just load up the game and once it reached main menu, alt+tab over to Task Manager and change the affinity what's the big deal

Using Task Manager is the manual way and I'm trying to work out a way to automate it which I know is possible I just need to confirm the syntax and hex values. I launch and quit the game a lot while I'm modding the lua scripting so automating is preferable and more convenient than alt+tab and I avoid minimising games as much as possible. Using software would be overkill when I know I can find a solution eventually without it.

I don't have a password to WIFI at 1Gbps lan on my router and have original antyvirus and you can stay near fence.
I reinstalled original Windows 11 by phone with onedrive.
If you want you can come to my zone.
But with for that all

Processor use 0 or 1 could you explain

Modern processors, including those made by Intel and AMD, are capable of processing billions of instructions per second. This is made possible by the fact that modern processors contain multiple cores, as well as much faster clock speeds compared to previous generations of processors.
Last edited by Piotrex43; Sep 28, 2024 @ 7:21pm
Bad 💀 Motha Sep 28, 2024 @ 7:10pm 
Originally posted by perfect:
Originally posted by arottweiler:

Using Task Manager is the manual way and I'm trying to work out a way to automate it which I know is possible I just need to confirm the syntax and hex values. I launch and quit the game a lot while I'm modding the lua scripting so automating is preferable and more convenient than alt+tab and I avoid minimising games as much as possible. Using software would be overkill when I know I can find a solution eventually without it.

I don't have a password to WIFI at 1Gbps lan on my router and have original antyvirus.
I reinstalled original Windows 11 by phone with onedrive.
If you want you can come to my zone.
But with for that all

You sure you're replying to the correct thread? WTF this have to do with download speeds, or Win11 for that matter?
arottweiler (Banned) Sep 28, 2024 @ 7:13pm 
Originally posted by perfect:
Originally posted by arottweiler:

Using Task Manager is the manual way and I'm trying to work out a way to automate it which I know is possible I just need to confirm the syntax and hex values. I launch and quit the game a lot while I'm modding the lua scripting so automating is preferable and more convenient than alt+tab and I avoid minimising games as much as possible. Using software would be overkill when I know I can find a solution eventually without it.

I don't have a password to WIFI at 1Gbps lan on my router and have original antyvirus.
I reinstalled original Windows 11 by phone with onedrive.
If you want you can come to my zone.
But with for that all

I'm not sure what you mean. Was that meant to be posted on another thread?
arottweiler (Banned) Sep 28, 2024 @ 7:41pm 
Originally posted by _I_:
its binary to decimal/hex conversion that needs to be done

each binary bit is position of core number in reverse, 0 = off, 1 = on

00000001 = 1
00000010 = 2
00000100 = 4
00001000 = 8
00010000 = 16
00100000 = 32
01000000 = 64
10000000 = 128

and so on

add them up to assign specific cores

cores 0+1+2+3 = 00001111 = 15 = or in hex = 0xF

Thanks, that's very useful and I'll do some more testing with a shortcut. I've just found out that xrEngine.exe contains this line as part of the script:

SetThreadAffinityMask(GetCurrentThread(), 1);

The game is launched with Stalker-COP.exe but xrEngine is the process that appears in Task Manager and can be right clicked to change priority and affinity settings. Maybe SetThreadAffinityMask is read after my modified shortcut so the only option is to change affinity settings after the game has launched which has to be the Task Manager option.

It would be consistent with how my changes to affinity settings in Task Manager don't work if I do it very quickly and it only works if I wait for a few seconds for the game to launch properly and not just has xrEngine.exe in the processes list. xrEngine.exe appears as a running process five or six seconds before the game launches but disabling/enabling the affinity cores in Task Manager in those few seconds will not work and I suspect it's because xrEngine.exe contains the SetThreadAffinityMask command.

I've never decompiled an .exe before but could it be a simple case of using a decompiling utility to open xrEngine.exe in to an editable format, remove the line with SetThreadAffinityMask and recompile to create an identical file but without the affinity restriction?
Bad 💀 Motha Sep 28, 2024 @ 7:48pm 
All 3 of the original STALKER games can run perfectly fine on multi-threads CPUs; I played them back on my old AMD CPUs that had 2 and 4 Cores (two different PCs over time) one was Athlon64 and the other was a Phenom 1st gen. No issues.

The only issues I had with those game really is that they are unstable if you have Windows PageFile set to Auto/System Managed. Back in the day when I only had maybe 2 or 3 GB of system RAM I would set the PageFile MIN = 4GB and MAX = 8GB and then the games in general worked fine and were stable. Today if you have anywhere from 8GB of RAM or higher then I'd set the MIN = 8GB and the max to 1.5X your installed RAM; so if say 32GB installed RAM, set the MAX to 48GB (the # values for PageFile have to be input in MB values though; so 8 x 1024 = 8192 for example.
Last edited by Bad 💀 Motha; Sep 28, 2024 @ 7:50pm
arottweiler (Banned) Sep 28, 2024 @ 8:11pm 
Originally posted by Bad 💀 Motha:
All 3 of the original STALKER games can run perfectly fine on multi-threads CPUs; I played them back on my old AMD CPUs that had 2 and 4 Cores (two different PCs over time) one was Athlon64 and the other was a Phenom 1st gen. No issues.

The only issues I had with those game really is that they are unstable if you have Windows PageFile set to Auto/System Managed. Back in the day when I only had maybe 2 or 3 GB of system RAM I would set the PageFile MIN = 4GB and MAX = 8GB and then the games in general worked fine and were stable. Today if you have anywhere from 8GB of RAM or higher then I'd set the MIN = 8GB and the max to 1.5X your installed RAM; so if say 32GB installed RAM, set the MAX to 48GB (the # values for PageFile have to be input in MB values though; so 8 x 1024 = 8192 for example.

I never said I have performance issues with the Stalker games. No offence but if you don't know the answer to my question there's no need to start posting about something unrelated like RAM and pagefiles. That has nothing to do with what I'm trying to achieve.

Unless I can work out a way to edit xrEngine and remove or amend the SetThreadAffinityMask reference it seems my only option is to use Task Manager because changing it any other way is being cancelled out by the use of SetThreadAffinityMask in xrEngine.exe. I don't know that for certain but I suspect that is the case.
Bad 💀 Motha Sep 28, 2024 @ 9:42pm 
Yes with some older games it was like this; where after the game loads up it was best to ALT+TAB over to Task Manager (Details tab) and then change Affinity to 1 Core/Thread and click OK. Then do it again and select ALL Cores/Threads and click OK; then switch back to the game. The thread scheduling in WinOS should then properly balance the load and provide proper game smoothness.
Last edited by Bad 💀 Motha; Sep 28, 2024 @ 9:43pm
< >
Showing 1-13 of 13 comments
Per page: 1530 50

Date Posted: Sep 28, 2024 @ 10:55am
Posts: 13