Skip to main content
gamedev.net
🔒 Locked

Small question about boost::thread

Started by Andreas Persson Apr 24, 2009 at 3:52 AM 4 replies 900+ views
Original Post
Andreas Persson
Andreas Persson
Hi when I create a number of threads with boost::thread or boost::thread_group do they automaticly map to different cores if they are available?
Casual game dev www.apgames.se
_the_phantom_
_the_phantom_
Maybe; it all depends on how the OS wants to schedule them.
Andreas Persson
Andreas Persson
Is there a way to force the use of the available cores on windows?
Casual game dev www.apgames.se
_the_phantom_
_the_phantom_
Well, you can set ThreadAffinity however this can mess up the scheduler slightly.

That said, the window scheduler is generally going to do 'the right thing' with regards to allocating resources so its probably not something you need to worry about. The biggest problem is being bounced from core to core, however this tends to be down to the usage of sleep() instead of SwitchToThread(), the latter apprently stopping, or at least helping, that problem.
Codeka
Codeka
You can use SetThreadAffinity, but is there any particular reason why you think you need this? Typically the OS does the best job possible.

Edit: too slow!
Andreas Persson
Andreas Persson
Ok then I´ll put my trust in my OS and hope he performs well :) thanks guys
Casual game dev www.apgames.se

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.