0

I'm having some issues getting a batch file to set affinity for a game I'm hosting multiple servers of.

It uses the same exe file (DCS.exe) for each instance but I want it to run each of the five instances in a different core instead of doing what it likes to do (as the game is not multithreaded and is pretty poorly coded),

I have a batch file that starts my 5 server instances, but I'm trying to get it to work so that each instance runs in its own core on the CPU..... I have lots of cores so its not a problem but instead of DCS trying to run all 5 instances in one core as it does by default, I want it to run each instance in a separate core

This is what I have currently and it works great for running without affinity:

:loop
timeout /t 5 >nul
::REM -- wait before launching CF CAPTURE
Start "" /affinity 3 /high "E:\DCS\bin\DCS.exe" --norender --server -w CF_CAPTURE
timeout /t 5 >nul 
::REM -- wait before launching SF CAPTURE
Start "" /affinity C /high "E:\DCS\bin\DCS.exe" --norender --server -w SF_CAPTURE
timeout /t 5 >nul 
::REM -- wait before launching ROUND TABLE CAUCASUS
Start "" /affinity 30 /high "E:\DCS\bin\DCS.exe" --norender --server -w ROUND_TABLE_GC
timeout /t 5 >nul
::REM -- wait before launching ROUND TABLE PERSIAN GULF
Start "" /affinity C0/high "E:\DCS\bin\DCS.exe" --norender --server -w ROUND_TABLE_PERSIA
timeout /t 5 >nul 
::REM -- wait before launching BONUS SERVER BS_CAPTURE
Start "" /affinity 300 /high "E:\DCS\bin\DCS.exe" --norender --server -w BS_CAPTURE
timeout /t 36030 /nobreak
::REM -- amount of time for servers to run
taskkill /f /im DCS.exe 
goto loop
Exit
Nimantha
  • 5,793
  • 5
  • 23
  • 56
  • 1
    Does this answer your question? [Set affinity with start /AFFINITY command on Windows 7](https://stackoverflow.com/questions/7759948/set-affinity-with-start-affinity-command-on-windows-7) – Squashman Jul 03 '20 at 14:34
  • Sort of but not fully. I'm headed to work now but I will post later with an explanation, if I run /affinity 3 for example all 5 processes still run on the 1st core for some reason instead of core 2 which is what /affinity 3 should do if I'm not mistaken, I was curious if the formating of my /affinity command was correct.) in the correct place in the batch file etc. Thanks though. –  Jul 03 '20 at 14:41
  • Affinity 3 three means use CPU 0 and CPU 1. Affinity 1 is CPU 0. Affinity 2 is CPU 1. Affinity 4 is CPU 2. Affinity 8 is cpu 3. ETC....... This is a simple binary to hex conversion. Binary is 8 bits. Read it right to left. Plenty of binary to hex calculators on the Internet. The link I post explains it pretty clearly in my opinion. – Squashman Jul 03 '20 at 14:48
  • OK so having read what u just typed it dawned on my what I was doing incorrectly but even so setting it as the following for each dcs.exe instance : CPU 0 i.e. (/affinity 1) CPU 1(/affinity 2) CPU 2 (/affinity 4) CPU 3 (/affinity 8) and finally CPU 4 (/affinity 16) but alas all 5 instances of dcs.exe still run on core 1 (CPU 0 in task manager performance tab). –  Jul 03 '20 at 15:29

0 Answers0