Use pthread_attr_init(3T) to initialize object attributes to their default values. The storage is allocated by the thread system during execution.
Prototype: int pthread_attr_init(pthread_attr_t *tattr);
#include <pthread.h> pthread_attr_t tattr; int ret; /* initialize an attribute to the default value */ ret = pthread_attr_init(&tattr);
The default values for attributes (tattr) are:
Table 3-1 Default Attribute Values for tattr
Attribute |
Value |
Result |
---|---|---|
scope |
PTHREAD_SCOPE_PROCESS |
New thread is unbound - not permanently attached to LWP. |
detachstate |
PTHREAD_CREATE_JOINABLE |
Exit status and thread are preserved after the thread terminates. |
stackaddr |
NULL |
New thread has system-allocated stack address. |
stacksize |
1 megabyte |
New thread has system-defined stack size. |
priority |
|
New thread inherits parent thread priority. |
inheritsched |
PTHREAD_INHERIT_SCHED |
New thread inherits parent thread scheduling priority. |
schedpolicy |
SCHED_OTHER |
New thread uses Solaris-defined fixed priority scheduling; threads run until preempted by a higher-priority thread or until they block or yield. |
Returns zero after completing successfully. Any other returned value indicates that an error occurred. If the following condition occurs, the function fails and returns the corresponding value.
ENOMEM
Returned when there is not enough memory to initialize the thread attributes object.