NAME

pthread_attr_init, pthread_attr_destroy, pthread_attr_setdetachstate, pthread_attr_getdetachstate, pthread_attr_setschedparam, pthread_attr_getschedparam - thread attribute operations

LIBRARY

POSIX Thread Library (libpthread, -lpthread)

SYNOPSIS



int pthread_attr_init(pthread_attr_t *attr)

int pthread_attr_destroy(pthread_attr_t *attr)

int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate)

int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate)

int pthread_attr_setschedparam(pthread_attr_t * restrict attr, const struct sched_param * restrict param)

int pthread_attr_getschedparam(const pthread_attr_t * restrict attr, struct sched_param * restrict param)

DESCRIPTION

Thread attributes are used to specify parameters to pthread_create(). One attribute object can be used in multiple calls to pthread_create(), with or without modifications between calls.

The pthread_attr_init() function initializes attr with all the default thread attributes.

The pthread_attr_destroy() function destroys attr.

The pthread_attr_set*() functions set the attribute that corresponds to each function name.

The pthread_attr_get*() functions copy the value of the attribute that corresponds to each function name to the location pointed to by the second function parameter.

The attribute parameters for the pthread_attr_setdetachstate() and pthread_attr_getdetachstate() are mutually exclusive and must be one of:

PTHREAD_CREATE_JOINABLE
The threads must explicitly be waited for using the pthread_join() function once they exit for their status to be received and their resources to be freed. This is the default.

PTHREAD_CREATE_DETACHED
The thread's resources will automatically be freed once the thread exits, and the thread will not be joined.

RETURN VALUES

If successful, these functions return 0. Otherwise, an error number is returned to indicate the error.

ERRORS

pthread_attr_init() shall fail if:

[ENOMEM]
Out of memory.

pthread_attr_destroy() may fail if:

[EINVAL]
The value specified by attr is invalid.

pthread_attr_setdetachstate() shall fail if:

[EINVAL]
The value specified by detachstate is invalid.

pthread_attr_setschedparam() may fail if:

[EINVAL]
The value specified by attr is invalid.

[ENOTSUP]
The value specified by param is invalid.

SEE ALSO

pthread_create(3), pthread_join(3)

STANDARDS

pthread_attr_init(), pthread_attr_destroy(), pthread_attr_setdetachstate(), pthread_attr_getdetachstate(), pthread_attr_setschedparam(), and pthread_attr_getschedparam() conform to ISO/IEC 9945-1:1996 (``POSIX.1'') .