3

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.

Andrew
  • 7,772
  • 3
  • 34
  • 43
James T
  • 147
  • 1
  • 9

2 Answers2

5

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.

Ryan Ries
  • 55,011
  • 9
  • 138
  • 197
2

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.

EEAA
  • 108,414
  • 18
  • 172
  • 242