Hi Andreas, Setting of the processor affinity of threads in osgViewer is something I'd like to make more configurable, but even with that I still don't understand when threads created after the viewer can't set their own affinity. Could you explain why the threads created later can't set affinity?
Robert. On Fri, Nov 5, 2010 at 10:00 AM, Anders Backman <[email protected]> wrote: > Using OSG 2.8.3 under windows 7 64bit. VS2008. > Hi, we discovered a problem where OSG hijacks the affinity for threading > in void ViewerBase::setUpThreading(): > ViewerBase.cpp: > // we'll set processor affinity here to help single threaded > apps > // with multiple processor cores, and using the database pager. > int numProcessors = OpenThreads::GetNumberOfProcessors(); > bool affinity = numProcessors>1; > if (affinity) > { > OpenThreads::SetProcessorAffinityOfCurrentThread(0); > > This means that, IF osg viewer is initialized before an app want to setup > threads, any threads started after that will get affinity(0), that is stick > to one core. > viewer.setupViewer( osg::Viewer::SingleThreaded ); > createMyOwnThreads(); // sticks to CPU0. > Just because osg want to run on one thread, does not automatically mean that > all other API:s want to stick to that main CPU. > Any threads that should run on other CPU:s needs to be created BEFORE > osg::viewer is initialized, not always the case. > Assume a thread is created from the keypress of a user? > What we do now is to reset the threadmask after setupViewer is called. > Then we get all the core-usage we want :-) > Just wanted to share the experience. > Keep up the excellent work! > > /Anders > > -- > > _______________________________________________ > osg-users mailing list > [email protected] > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

