Creates a thread attributes object and initializes it with default values.
Threads Library (libpthreads.a)
#include <pthread.h>
int pthread_attr_init ( attr)
pthread_attr_t *attr;
The pthread_attr_init subroutine creates a new thread attributes object attr. The new thread attributes object is initialized with the following default values:
Attribute | Default value |
---|---|
Detachstate | PTHREAD_CREATE_JOINABLE |
Contention-scope | PTHREAD_SCOPE_SYSTEM the default ensures compatibility with implementations that do not support this POSIX option. |
Inheritsched | PTHREAD_INHERITSCHED |
Schedparam | A sched_param structure which sched_prio field is set to 1, the least favored priority. |
Schedpolicy | SCHED_OTHER |
Stacksize | PTHREAD_STACK_MIN |
Guardsize | PAGESIZE |
The resulting attribute object (possibly modified by setting individual attribute values), when used by pthread_create, defines the attributes of the thread created. A single attributes object can be used in multiple simultaneous calls to pthread_create.
Item | Description |
---|---|
attr | Specifies the thread attributes object to be created. |
Upon successful completion, the new thread attributes object is filled with default values and returned via the attr parameter, and 0 is returned. Otherwise, an error code is returned.
The pthread_attr_init subroutine is unsuccessful if the following is true:
Item | Description |
---|---|
EINVAL | The attr parameter is not valid. |
ENOMEM | There is not sufficient memory to create the thread attribute object. |
This function will not return an error code of [EINTR].