Does POSIX standard say EXPLICIT or IMPLICIT SCHED

Joel Sherrill joel.sherrill at OARcorp.com
Wed Dec 4 16:53:11 UTC 2002



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

This is what I was leaning to.  I saw that phrasing in
pthread_attr_init()
and pthread_create().  I went so far as to look at the list of
official interpretations on the IEEE site but nothing was mentioned.

> >   Does anyone out there
> > know what The Right Thing To Do (TM) is?
> IMO: "You must not rely on any implicit defaults".

Yep.  :(  This is quite a shame since it means that a truly portable
application must initialize an attributes structure and use that.

I will add this from the LynxOS 4.0.0 POSIX Conformance documentation:

> pthread_attr_t
>   The default attributes for a created thread, when pthread_create() 
>   is called with a pointer to an initialized pthread_attr_t 
>   (via pthread_attr_init()) is as follows: 
>       The stacksize attribute is 4 Mb. 
>       The stackaddr attribute is not supported since 
>         {POSIX_THREAD_ATTR_STACKADDR} is not defined. 
>       The inheritsched attribute is PTHREAD_INHERIT_SCHED. 
>       The priority attribute is irrelevant, since the priority is 
>          inherited from the caller of pthread_create (). 
>       The schedpolicy attribute is SCHED_FIFO. 
>       The detachstate attribute is PTHREAD_CREATE_JOINABLE. 
>       The contentionscope attribute is PTHREAD_SCOPE_SYSTEM. 
>         However, this attribute is not considered when creating 
>         a thread under LynxOS, because all threads compete for 
>         resources on a system-wide basis. 
>       The guardsize attribute (from P1003.1j Draft 7) is PAGESIZE. 
> 

So now we have the two for each decision.  :)  

> 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