Open System Services System Calls Reference Manual (G06.25+, H06.03+)

pthread_attr_init(2) OSS System Calls Reference Manual
NAME
pthread_attr_init - Initializes a thread attributes object
LIBRARY
G-series native OSS processes: /G/system/sysnn/zsptsrl
H-series OSS processes: /G/system/zdllnnn/zsptdll
SYNOPSIS
#include <spthread.h>
int pthread_attr_init(
pthread_attr_t *attr );
PARAMETERS
attr species the address of the thread attributes object to be initialized.
DESCRIPTION
This function initializes the thread attributes object specied by the attr parameter with a set of
default attribute values. A thread attributes object is used to specify the attributes of threads
when they are created. A thread attributes object created by this function is used only in calls to
the pthread_create() function.
The following functions change individual attributes of an initialized thread attributes object:
pthread_attr_setdetachstate()
pthread_attr_setguardsize_np( )
pthread_attr_setinheritsched()
pthread_attr_setschedparam()
pthread_attr_setschedpolicy()
pthread_attr_setstacksize()
The attributes of a thread attributes object are initialized to default values. The default value of
each attribute is discussed in the reference page for the corresponding function listed above.
When a thread attributes object is used to create a thread, the objects attribute values determine
the characteristics of the new thread. Thus, thread attributes objects act as additional arguments
to thread creation. Changing the attributes of a thread attributes object does not affect any
threads that were previously created using that thread attributes object.
You can use the same thread attributes object in successive calls to pthread_create(), from any
thread. (However, you cannot use the same value of the stack address attribute to create multiple
threads that might run concurrently; threads cannot share a stack.) If more than one thread might
change the attributes in a shared thread attributes object, your program must use a mutex to pro-
tect the integrity of the thread attributes objects contents.
When you set the scheduling policy or scheduling parameters, or both, of a thread attributes
object, scheduling inheritance must be disabled if you want the scheduling attributes you set to
be used at thread creation. In the HP implementation, the default value of
PTHREAD_EXPLICIT_SCHED for the inherit attribute of a new thread automatically dis-
ables scheduling inheritance. At thread creation, the scheduling policy and scheduling parame-
ters stored in the thread attributes object passed to the pthread_create() function are used by
default. To enable scheduling inheritance, before creating the new thread use the
pthread_attr_setinheritsched() function to specify the value PTHREAD_INHERIT_SCHED
for the inherit parameter.
526 Hewlett-Packard Company 527186-003