pthread_attr_init(3P)
pthread_attr_init, pthread_attr_destroy, pthread_attr_setstacksize, pthread_attr_getstacksize, pthread_attr_setstackaddr, pthread_attr_getstackaddr, pthread_attr_setdetachstate, pthread_attr_getdetachstate - initialize thread attributes
Showing IRIX 6.5.30 (default release). Unchanged since IRIX 6.5.
NAME pthread_attr_init, pthread_attr_destroy, pthread_attr_setstacksize, pthread_attr_getstacksize, pthread_attr_setstackaddr, pthread_attr_getstackaddr, pthread_attr_setdetachstate, pthread_attr_getdetachstate - initialize thread attributes C SYNOPSIS #include <pthread.h> int pthread_attr_init(pthread_attr_t *attr); int pthread_attr_destroy(pthread_attr_t *attr); int pthread_attr_setstacksize(pthread_attr_t *attr, size_t size); int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *size); int pthread_attr_setstackaddr(pthread_attr_t *attr, void *addr); int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **addr); int pthread_attr_setdetachstate(pthread_attr_t *attr, int detach); int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detach); DESCRIPTION A thread attributes object is a collection of values which specify how a thread is created [see pthread_create()]. Changes to the attribute values of the object do not affect threads already created using the object. Size and location of the stack may be specified as well as the detached state [see pthread_detach()] and scheduling attributes [see pthread_attr_setscope() and pthread_attr_setinheritsched(3P)]. The pthread_attr_init() function initializes the thread attributes object specified by attr and the function pthread_attr_destroy() destroys it. The stack size attribute is the minimum number of bytes used by a thread for its stack. It is set in the object attr to the value of size using pthread_attr_setstacksize(). The current stack size for the attribute object attr is returned in the size parameter of pthread_attr_getstacksize(). The best way to find the default stacksize is to retrieve it from an initialized attribute object. In IRIX this value is 0x20000 (128k) bytes. The stack address attribute is the address of storage allocated by the user that a thread will use as its stack. It is set in the object attr to the value of addr using pthread_attr_setstackaddr(). If an address is specified it must reference memory of at least the size indicated by the stack size attribute value. When no attribute value is specified memory will be allocated at an address chosen by the library and disposed of when the thread terminates. The current stack address for the attribute object attr is returned in the addr parameter of pthread_attr_getstackaddr(). It is meaningless to request a value for the address attribute if none has been set. The detach state attribute determines whether storage for the thread will be reclaimed when it terminates. It is set in the object attr to the value of detach using pthread_attr_setdetachstate(). A value of either PTHREAD_CREATE_JOINABLE (which is the default) or PTHREAD_CREATE_DETACHED should be specified. The initial thread is created with the detach state of PTHREAD_CREATE_JOINABLE. The current detach state for the attribute object attr is returned in the detach parameter of pthread_attr_getdetachstate(). DIAGNOSTICS On success the attribute functions return zero; otherwise they return an error number. pthread_attr_setstacksize() can return the following error: [EINVAL] The stack size specified by size is too small [see NOTES]. pthread_attr_setstackaddr() can return the following error: [EINVAL] The stack address specified by addr is illegal. pthread_attr_setdetachstate() can return the following error: [EINVAL] The value of detach is neither PTHREAD_CREATE_JOINABLE nor PTHREAD_CREATE_DETACHED. SEE ALSO pthread_create(3P), pthread_detach(3P), sysconf(3C). NOTES The minimum stack size can be retrieved using sysconf(3C) using the THREAD_STACK_MIN option.