Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any way to force a program to run on cpu1 rather than cpu0 given that I know that there are at least two cores?

I'm compiling C++ with code::blocks on Windows 7 x64

share|improve this question
1  
I'd lean toward saying this is a SO question. –  rob Jul 14 '11 at 0:08
add comment

2 Answers

up vote 8 down vote accepted

I know that you can pull up task manager and look for your application that is running. Right click on the application in the task manager and select Affinity.

enter image description here

Then you can select the processors you wish to use.

enter image description here

share|improve this answer
1  
Note that I don't think this is a GUARANTEE that they'll only run on the selected cores, only quite literally an affinity. If there are threads that Windows feels it A: Can move and B: Should move, it C: Will move them. This also doesn't keep other things from running on those cores (which is the subject of a long standing question I have open :/) –  Shinrai Jul 14 '11 at 14:22
add comment

Yes there is in the Windows API: SetProcessAffinityMask(). You can also set a processes affinity using task manager as shown here.

There aren't very many valid reasons why you would want to do that. The OS generally does a good job of scheduling programs on the correct CPU.

share|improve this answer
    
Do you know if there is also a way to run a thread on a particular core? Because GSC Game World claimed in one update to S.T.A.L.K.E.R. that they moved the calculation of detailed objects to the second processor core and I can't imagine that they used a full-fletched process for that, a simple thread would make more sense. (stalker.filefront.com/file/…) –  Felix Dombek Jul 14 '11 at 6:08
2  
There is SetThreadAffinityMask(), but most likely S.T.A.L.K.E.R didn't use that. They just moved the calculation from their main game logic thread and put it in it's own dedicated thread and letting the OS handle scheduling the thread on a different CPU. –  shf301 Jul 14 '11 at 14:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.