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

Reply via email to