int pthread_attr_init(pthread_attr_t *attr);
int pthread_attr_destroy(pthread_attr_t *attr);
int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope);
int pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope);
int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
int pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate);
int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr);
int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr);
int pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param
*param);
int pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param
*param);
int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
int pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy);
int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
int pthread_attr_getinheritsched(const pthread_attr_t *attr, int *inheritsched);
All attributes in attr are independent of one another and may be singularly modified or retrieved. attr, itself, is independent of any thread and can be modified or used to create new threads. However, any change to attr after a thread is created will not affect that thread.
Attribute | Default | Value |
contentionscope | PTHREAD_SCOPE_PROCESS | resource competition within process |
detachstate | PTHREAD_CREATE_JOINABLE | joinable by other threads |
stackaddr | NULL | stack allocated by system |
stacksize | NULL | 1 megabyte |
priority | ---- | priority of parent (calling) thread |
policy | SCHED_OTHER | determined by system |
inheritsched | PTHREAD_EXPLICIT_SCHED | scheduling policy and parameters |
not inherited but explicitly defined | ||
by the attribute object |
NOTE: Attribute objects should be destroyed before an initialized attribute object is re-initialized.
The pthread_attr_setstackaddr() and pthread_attr_getstackaddr() functions set and get the stackaddr thread attribute in the attr object. The stackaddr default is NULL . (See pthread_create(3T) .)
Values for the policy attribute are SCHED_FIFO , SCHED_RR , or the default value SCHED_OTHER (see NOTES section below.
- ENOMEM
- Insufficient memory exists to create the thread attributes object.
If any of the following conditions occur, pthread_attr_setstacksize() returns the corresponding error number:
- EINVAL
- The value of stacksize is less than PTHREAD_STACK_MIN or exceeds a system-imposed limit.
If any of the following conditions occur, pthread_attr_destroy(), pthread_attr_setstacksize(), pthread_attr_getstacksize(), pthread_attr_setstackaddr(), pthread_attr_getstackaddr(), pthread_attr_setdetachstate(), pthread_attr_getdetachstate(), pthread_attr_setscope(), pthread_attr_getscope(), pthread_attr_setschedparam(), pthread_attr_getschedparam(), pthread_attr_setinheritsched(), pthread_attr_getinheritsched(), pthread_attr_setschedpolicy(), and pthread_attr_getschedpolicy() return the corresponding error number:
- EINVAL
- The value of attr is not valid.
If any of the following conditions occur, pthread_attr_setstacksize() returns the corresponding error number:
- EINVAL
- The value of stacksize is less than PTHREAD_STACK_MIN .
If any of the following conditions occur, pthread_attr_setdetachstate() returns the corresponding error number:
- EINVAL
- The value of detachstate is not valid.
If any of the following conditions occur, pthread_attr_setscope() returns the corresponding error number:
- EINVAL
- The value of contentionscope is not valid.
If any of the following conditions occur, pthread_attr_setschedparam() returns the corresponding error number:
- EINVAL
- The value of the sched_priority member of the param structure is less than or equal to 0.
If any of the following conditions occur, pthread_attr_getstacksize() returns the corresponding error number:
- EINVAL
- The value of stacksize is NULL .
If any of the following conditions occur, pthread_attr_getstackaddr() returns the corresponding error number:
- EINVAL
- The value of stackaddr is NULL .
If any of the following conditions occur, pthread_attr_getdetachstate() returns the corresponding error number:
- EINVAL
- The value of detachstate is NULL .
If any of the following conditions occur, pthread_attr_getscope() returns the corresponding error number:
- EINVAL
- The value of contentionscope is NULL .
If any of the following conditions occur, either pthread_attr_setschedparam() and pthread_attr_getschedparam() returns the corresponding error number:
- EINVAL
- The value of param is NULL .
For each of the following conditions, if the condition is detected, pthread_attr_setinheritsched() and pthread_attr_setschedpolicy() return the corresponding error number:
- ENOTSUP
- An attempt was made to set the attribute to an unsupported policy or inheritsched.
For each of the following conditions, if the condition is detected, pthread_attr_getinheritsched() and pthread_attr_getschedpolicy() return the corresponding error number:
- EINVAL
- policy or inheritsched is NULL .
The attribute object is part of the POSIX threads interface. There is no Solaris threads counterpart to the POSIX threads attribute object.