Default POSIX thread attributes?

Joel Sherrill joel.sherrill at OARcorp.com
Tue Feb 11 16:47:42 UTC 2003



gregory.menke at gsfc.nasa.gov wrote:
> 
> Vladimir Nesic writes:
>  > Current implementation of pthreads has a strange default attribute set,
>  > which is not documented, and it took me almost a whole month to find
>  > out why an app that worked on Linux stopped working on RTEMS.
> 
> These kinds of bugs can be <very> hard to track down on any operating
> system.  If you rely on default pthread behavior, you're going to have
> lots of problems.  The pthread interface kind of sucks in general- its
> advantage is its sort of portable.

The standard does not specify the default attributes as I recall.  If 
there is some piece of standard documentation RTEMS does not adhere
to, file a PR.

Otherwise, this falls into the "POSIX didn't cover this" category.

>  > 2) Default scheduler is SCHED_FIFO, which means that threads are started
>  > at sorpriseingly high priority.
> 
> This is likely not a priority problem as its possibly a scheduling
> algorithm problem.  As I understand it, only root can create non-round
> robin scheduled tasks in Linux.  Under RTEMS, you can choose priority
> scheduling or round robin as you like.  Perhaps you're not being
> exhaustive enough in your pthread attribute initialization.

That's really what you have to do with pthreads if you intend to know
what the behavior is.
 
>  > 3) Scheduler and priority are inheritied by default, instead of set to
>  > default value, which ever default vaule is.
> 
> We always use #ifdefs to create native RTEMS tasks on rtems or pthread
> tasks on Linux so we can take advantage of RTEMS when running on it.
> We never rely on Linux to provide specific realtime scheduling at this
> point.

That's what we have done on applications we consult on.  I have even 
conditionally added code to wrapper routines to ignore the no permission
error you get on Linux when you try it as root.

Bottom line.. if you want to be portable, you will have to be explicit
in your thread initialization.  If you find something that RTEMS does
differently from the Open Group Single UNIX Specification, file a PR.
This particular case is in the unfortunately underspecified world.


> Gregm

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel at OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985



More information about the users mailing list