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
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org