[osg-users] SingleThreaded leading to whole application just running on one core

Pete Black pete at marchingcubes.com
Thu Sep 22 21:25:06 PDT 2016


This is, bizarrely, by design.

In single-threaded mode, OpenSceneGraph silently sets CPU affinity to a single core by default. Personally I think this is incredibly obtrusive on the programmer, and the reasons for this being default behaviour are terrible, but it is what it is.

This is what I do:


Code:
#ifdef LINUX
    int numCPU = sysconf( _SC_NPROCESSORS_ONLN ); //glibc fails 'all ones' cpu masks so we need this sysconf call
    cpu_set_t  mask;
    CPU_ZERO(&mask);
    for (int i = 0; i < numCPU ; i++)
    {
        CPU_SET(i, &mask);
        //qDebug("SETTING CPU %d",i);
    }
    int ret = sched_setaffinity(0, sizeof(mask), &mask); //override OpenSceneGraphs shitty CPU affinity stuff
    //qDebug("CPU COUNT: %d %d",CPU_COUNT(&mask),ret);

#endif



------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=68702#68702








More information about the osg-users mailing list