Does POSIX standard say EXPLICIT or IMPLICIT SCHED

Joel Sherrill joel.sherrill at OARcorp.com
Wed Dec 4 17:18:07 UTC 2002



Till Straumann wrote:
> 
> I guess I was naive when I first wrote the benchmark code - I figured
> POSIX was a standard
> and hence the defaults would be standardized.

HAHAHAHA!!!  :)  The reason for this perception is that in general
things are portable.  It is at the edges that some things differ.
And where there has seemed to be a hole, we have done this type of
survey and usually found that most implementations agree.  In this
case, that doesn't appear to be the case.

> After discovering the problem, yesterday I did a similar research and
> came to the same
> conclusion: it seems that the defaults set by pthread_attr_init() are
> implementation dependent.
> 
> Here are more examples:
> IBM AIX unix uses INHERIT_SCHED by default, IBM OS/400's default is
> EXPLICIT_SCHED
> ;-)

So there you have it 3 out of 6 OSes agree. :)
 
> -- Till
> 
> Ralf Corsepius wrote:
> 
> >Am Mit, 2002-12-04 um 16.48 schrieb Joel Sherrill:
> >
> >
> >>>>My benchmark code fails to set PTHREAD_EXPLICIT_SCHED and hence
> >>>>the benchmark task runs at the wrong priority. I had developed the
> >>>>pthread stuff for RT-Linux (where EXPLICIT_SCHED is the default,
> >>>>as it is on some other systems, it seems).
> >>>>
> >>>>
> >>>I searched some last night
> >>>
> >>>
> >>and unfortunately did not complete this paragraph.  :(
> >>
> >>I looked to see what the POSIX or OpenGroup standards say about this
> >>and didn't find anything which gave me a clue.
> >>
> >>
> >
> >>>From SUSV3/pthread_attr_init():
> >
> >The pthread_attr_init() function shall initialize a thread attributes
> >object attr with the default value for all of the individual attributes
> >used by a given implementation.
> >
> >I read this as being "explicitly unspecific", i.e. "everything is
> >implementation-defined".
> >
> >
> >
> >>  Does anyone out there
> >>know what The Right Thing To Do (TM) is?
> >>
> >>
> >IMO: "You must not rely on any implicit defaults".
> >
> >
> >Anyway, from  Solaris-2.7's pthread_attr_init's man-page:
> >
> >     The pthread_attr_init() function initializes a thread attri-
> >     butes  object ( attr) with the default value for each attri-
> >     bute as follows:
> >
> >        Attribute           Default Value                Meaning of Default
> >     contentionscope   PTHREAD_SCOPE_PROCESS     resource competition within process
> >     detachstate       PTHREAD_CREATE_JOINABLE   joinable by other threads
> >     stackaddr         NULL                      stack allocated by system
> >     stacksize         NULL                      1 or 2 megabyte
> >     priority          0                         priority of the thread
> >     policy            SCHED_OTHER               determined by system
> >     inheritsched      PTHREAD_EXPLICIT_SCHED    scheduling  policy  and  parameters
> >                                                 not    inherited   but   explicitly
> >                                                 defined by the attribute object
> >     guardsize         PAGESIZE                  size of guard area for a  thread's
> >                                                 created stack
> >
> >Linux pthread_attr_init man-page
> >
> >   inheritsched
> >       Indicate whether the scheduling policy and  scheduling  parameters  for
> >       the  newly created thread are determined by the values of the schedpol-
> >       icy and schedparam attributes  (value  PTHREAD_EXPLICIT_SCHED)  or  are
> >       inherited from the parent thread (value PTHREAD_INHERIT_SCHED).
> >
> >       Default value: PTHREAD_EXPLICIT_SCHED.
> >
> >Ralf
> >
> >
> >
> >

-- 
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