[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]


pthread_attr_setinheritsched

Changes the inherit scheduling attribute of the specified thread attributes object.

Syntax

pthread_attr_setinheritsched(
                             attr,
                             inheritsched );
 


Argument Data Type Access

attr opaque pthread_attr_t write inheritsched integer read


C Binding

#include 

int pthread_attr_setinheritsched ( pthread_attr_t *attr, int inheritsched);

Arguments

attr
Thread attributes object to be modified.
inheritsched
New value for the inherit scheduling attribute. Valid values are as follows:
   PTHREAD_INHERIT_SCHED    The created thread inherits the
                            scheduling policy and associated
                            scheduling attributes of the thread
                            calling pthread_create. Any scheduling
                            attributes in the attributes object
                            specified by the pthread_create
                            attr argument are ignored
                            during thread creation. This is the
                            default value.

   PTHREAD_EXPLICIT_SCHED   The scheduling policy and associated
                            scheduling attributes of the created
                            thread are set to the corresponding
                            values from the attribute object
                            specified by the pthread_create 
                            attr argument.


Description

This routine changes the inherit scheduling attribute of thread creation. The inherit scheduling attribute specifies whether threads created using the specified attributes object inherit the scheduling attributes of the creating thread, or use the scheduling attributes stored in the attributes object specified by the pthread_ create attr argument.

The first thread in an application has a scheduling policy of SCHED_OTHER. See the pthread_attr_setschedparam and pthread_attr_ setschedpolicy routines for more information on valid priority values and valid scheduling policy values, respectively.

Inheriting scheduling attributes (instead of using the scheduling attributes stored in the attributes object) is useful when a thread is creating several helper threads-threads that are intended to work closely with the creating thread to cooperatively solve the same problem. For example, inherited scheduling attributes ensure that helper threads created in a sort routine execute with the same priority as the calling thread.

Return Values

If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Return        Description

0 Successful completion. [EINVAL] One or both of the values specified by inherit or by attr is invalid. [ENOTSUP] An attempt was made to set the attribute to an unsupported value.


Associated Routines

   pthread_attr_init
   pthread_attr_getinheritsched
   pthread_attr_setschedpolicy
   pthread_attr_setschedparam
   pthread_create



[Return to Bookshelf] [Contents] [Previous Section] [Next Section] [Index] [Help]