I have a program that runs on my server, I want to run multiple instances of the same program (its an application that can only run on a single core..), im wondering if I can assign them to a core at runtime? using a batch script or something? Im running windows server 2012.
-
Do you not trust the kernel's scheduler to sort this out on its own? – EEAA Feb 01 '14 at 18:08
-
Oh wait it does it automatically and im just being a moron right? – James T Feb 01 '14 at 18:18
-
If you have six cores, just start six copies of the program. – Michael Hampton Feb 01 '14 at 19:20
-
@James Trotter: http://stackoverflow.com/questions/7759948/set-affinity-with-start-affinity-command-on-windows-7 – Greg Askew Feb 02 '14 at 01:04
2 Answers
Wait a second... you asked a question, and you accepted an answer of "don't do that."
No one actually answered your question.
Please don't take me the wrong way. No offense at all to any of the other answerers, and I do agree with them that you're probably not thinking this all the way through if you have to ask this question in the first place... but, you asked a specific question nevertheless.
So here's the answer.
C:\Windows\system32>start /affinity 1 notepad.exe
That will start an instance of the Notepad.exe process set to an affinity to the first CPU only. You can mix and match CPUs (cores) if you wish, but you asked how to start a process on a single CPU.
You can verify that the command worked by checking the resulting processes' affinity in Task Manager or Process Explorer.
- 55,011
- 9
- 138
- 197
In the vast majority of circumstances, trying to manually manage process-to-CPU bindings will actually result in overall reduced performance than by just letting the kernel's CPU scheduler sort things out.
So, unless you run into some actual performance issues that can be directly traced back to CPU scheduling, this isn't something you need to think about.
- 108,414
- 18
- 172
- 242
-
Agreed - I've never had to manually assign cores outside of troubleshooting – Dan Feb 01 '14 at 18:59