Changes the inherit scheduling attribute of the specified thread attributes object.
pthread_attr_setinheritsched( attr, inherit );
Argument Data Type Accessattr opaque pthread_attr_t read inherit integer read
int pthread_attr_setinheritsched ( pthread_attr_t *attr, int inherit);
PTHREAD_INHERIT_ This is the default value. The created thread SCHED inherits the current priority and scheduling policy of the thread calling pthread_create. PTHREAD_DEFAULT_ The created thread starts execution with the SCHED priority and scheduling policy stored in the thread attributes object.
The first thread in an application that is not created by an explicit call to pthread_create has a scheduling policy of SCHED_ OTHER. See the pthread_attr_setprio and pthread_attr_setsched 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 Error Description0 Successful completion. -1 [EINVAL] The value specified by inherit is invalid. -1 [ESRCH] The value specified by attr does not refer to an existing thread attributes object.