Hi Curtis,

There has to be a historical reason for need for the #ifndef __linux__
around the thread scheduling assignment.  As I'm not the author of
this block of code I can only check the code and svn log's.  I'm
currently working on a complex bug fix on another area of the OSG so
can't dive into a new area of code right now.

Given there has to be a reason for the special handling under Linux we
can't just remove the block and hope for the best.  It may be possible
to specialize the #ifndef to allow certain combinations for linux to
work, but we'd need to track down which combinations we might expect
to work and which ones might not so we can determine the right type of
checks to apply.  This is why the history is important.  I'm guessing
there older versions of Linux didn't fully implement pthreads/pthread
extensions.  I have to defer to others in this department though, as I
don't have experience with all variants of pthreads on linux though
time.

Robert.

On 4 May 2015 at 15:26, Curtis Rubel <cru...@compro.net> wrote:
> Robert,
>
> When I mentioned crippled, I did not mean that as a bad or derogatory
> comment.  Maybe saying something like intentionally disabled would have
> been a better choice of words, my apologies if my wording offended anyone in 
> any way.
>
> Basic threading is working fine under Linux.  If the user however wants to
> take advantage of all of the available threading policies and priorities now 
> available to them they cannot.  I think that this is just possibly just due 
> to this section of Openthreads not being updated when these features were 
> fully implemented and properly working on the linux platform.
>
> Here is a code excerpt of the SetThreadSchedulingParams
> function call within OpenThreads/phhreads/PThread.cpp
>
>
> Code:
>
>     
> //--------------------------------------------------------------------------
>     // Set thread scheduling parameters.  Unfortunately on Linux, there's no
>     // good way to set this, as pthread_setschedparam is mostly a no-op.
>     //
>     static int SetThreadSchedulingParams(Thread *thread)
>     {
>
>         int status = 0;
>
> #ifdef ALLOW_PRIORITY_SCHEDULING // [
>
>         if(sysconf(_POSIX_THREAD_PRIORITY_SCHEDULING))
>         {
>
>             int th_policy;
>             int max_priority, nominal_priority, min_priority;
>             sched_param th_param;
>             pthread_getschedparam(thread->getProcessId(),
>                       &th_policy, &th_param);
>
> #ifndef __linux__
>
>             switch(thread->getSchedulePolicy())
>             {
>
>                 case Thread::THREAD_SCHEDULE_FIFO:
>                 th_policy = SCHED_FIFO;
>                 break;
>
>                 case Thread::THREAD_SCHEDULE_ROUND_ROBIN:
>                 th_policy = SCHED_RR;
>                 break;
>
>                 case Thread::THREAD_SCHEDULE_TIME_SHARE:
>                 th_policy = SCHED_OTHER;
>                 break;
>
>                 default:
> #ifdef __sgi
>                 th_policy = SCHED_RR;
> #else
>                 th_policy = SCHED_FIFO;
> #endif
>                 break;
>             };
>
> #else
>             th_policy = SCHED_OTHER;  // Must protect linux from realtime.
> #endif
>
> #ifdef __linux__
>
>             max_priority = 0;
>             min_priority = 20;
>             nominal_priority = (max_priority + min_priority)/2;
>
> #else
>
>             max_priority = sched_get_priority_max(th_policy);
>             min_priority = sched_get_priority_min(th_policy);
>             nominal_priority = (max_priority + min_priority)/2;
>
> #endif
>
>             switch(thread->getSchedulePriority())
>             {
>
>                 case Thread::THREAD_PRIORITY_MAX:
>                     th_param.sched_priority = max_priority;
>                     break;
>
>                 case Thread::THREAD_PRIORITY_HIGH:
>                     th_param.sched_priority = (max_priority + 
> nominal_priority)/2;
>                     break;
>
>                 case Thread::THREAD_PRIORITY_NOMINAL:
>                     th_param.sched_priority = nominal_priority;
>                     break;
>
>                 case Thread::THREAD_PRIORITY_LOW:
>                     th_param.sched_priority = (min_priority + 
> nominal_priority)/2;
>                     break;
>
>                 case Thread::THREAD_PRIORITY_MIN:
>                     th_param.sched_priority = min_priority;
>                     break;
>
>                 default:
>                     th_param.sched_priority = max_priority;
>                     break;
>
>             }
>
>             status = pthread_setschedparam(thread->getProcessId(),
>                            th_policy,
>                            &th_param);
>
>
>             if(getenv("OUTPUT_THREADLIB_SCHEDULING_INFO") != 0)
>             PrintThreadSchedulingInfo(thread);
>
>         }
>
> #endif // ] ALLOW_PRIORITY_SCHEDULING
>
>     return status;
>     };
>
>
>
>
>
> You can see in this excerpt that on Linux platforms the code to allow you to 
> select any of the available threading policies is allowed on all platforms 
> but linux.  Linux is hard-coded to set the SCHED_OTHER policy.
>
> The other sections of the code excerpt limit the range of priorities allowed 
> to between 0 and 20, when linux currently has a range of 0 - 99, 99 being the 
> highest priority allowed.  The associated calls to sched_get_priority_max and 
> sched_get_priority_min are not allowed on the linux platform.
>
> I will be happy to provide you with a sample application if you still would 
> like to have one, but I think the ifndef's in the code will let you see what 
> I am referring too.
>
> Again I apologize if I offended anyone, that was not my intention.
>
> ...
>
> Thank you!
>
> Cheers,
> Curtis
> Code:
>
>
>
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=63627#63627
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to