174 lines
4.1 KiB
Plaintext
174 lines
4.1 KiB
Plaintext
'\"macro stdmacro
|
|
.\"
|
|
.\" ----------------
|
|
.TH pthread_attr_init 3P
|
|
.\"
|
|
.\" ----------------
|
|
.SH 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
|
|
.\"
|
|
.\" ----------------
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
.nf
|
|
.ft 3
|
|
#include <pthread.h>
|
|
.sp .8v
|
|
.ft 3
|
|
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);
|
|
.ft 1
|
|
.fi
|
|
.Op
|
|
.\"
|
|
.\" ----------------
|
|
.SH DESCRIPTION
|
|
A thread attributes object is a collection of values which specify how
|
|
a thread is created [see
|
|
.IR 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
|
|
.IR pthread_detach ()]
|
|
and scheduling attributes [see
|
|
.IR pthread_attr_setscope ()
|
|
and
|
|
.IR pthread_attr_setinheritsched (3P)].
|
|
.\"
|
|
.PP
|
|
The
|
|
.IR pthread_attr_init ()
|
|
function initializes the thread attributes object specified by
|
|
.I attr
|
|
and the function
|
|
.IR pthread_attr_destroy ()
|
|
destroys it.
|
|
.\"
|
|
.PP
|
|
The stack size attribute is the minimum number of bytes used by a
|
|
thread for its stack.
|
|
It is set in the object
|
|
.I attr
|
|
to the value of
|
|
.I size
|
|
using
|
|
.IR pthread_attr_setstacksize ().
|
|
The current stack size for the attribute object
|
|
.I attr
|
|
is returned in the
|
|
.I size
|
|
parameter of
|
|
.IR 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.
|
|
.\"
|
|
.PP
|
|
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
|
|
.I attr
|
|
to the value of
|
|
.I addr
|
|
using
|
|
.IR 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
|
|
.I attr
|
|
is returned in the
|
|
.I addr
|
|
parameter of
|
|
.IR pthread_attr_getstackaddr ().
|
|
It is meaningless to request a value for the address attribute if none
|
|
has been set.
|
|
.\"
|
|
.PP
|
|
The detach state attribute determines whether storage for the thread will
|
|
be reclaimed when it terminates.
|
|
It is set in the object
|
|
.I attr
|
|
to the value of
|
|
.I detach
|
|
using
|
|
.IR pthread_attr_setdetachstate ().
|
|
A value of either
|
|
.B PTHREAD_CREATE_JOINABLE
|
|
(which is the default) or
|
|
.B PTHREAD_CREATE_DETACHED
|
|
should be specified.
|
|
The initial thread is created with the detach state of
|
|
.BR PTHREAD_CREATE_JOINABLE .
|
|
The current detach state for the attribute object
|
|
.I attr
|
|
is returned in the
|
|
.I detach
|
|
parameter of
|
|
.IR pthread_attr_getdetachstate ().
|
|
.\"
|
|
.\" ----------------
|
|
.SH DIAGNOSTICS
|
|
On success the attribute functions
|
|
return zero; otherwise they return an error number.
|
|
.\"
|
|
.PP
|
|
.IR pthread_attr_setstacksize ()
|
|
can return the following error:
|
|
.\"
|
|
.TP 15
|
|
.B [EINVAL]
|
|
The stack size specified by
|
|
.I size
|
|
is too small [see
|
|
.BR NOTES ].
|
|
.\"
|
|
.PP
|
|
.IR pthread_attr_setstackaddr ()
|
|
can return the following error:
|
|
.\"
|
|
.TP 15
|
|
.B [EINVAL]
|
|
The stack address specified by
|
|
.I addr
|
|
is illegal.
|
|
.\"
|
|
.PP
|
|
.IR pthread_attr_setdetachstate ()
|
|
can return the following error:
|
|
.\"
|
|
.TP 15
|
|
.B [EINVAL]
|
|
The value of
|
|
.I detach is neither
|
|
.B PTHREAD_CREATE_JOINABLE
|
|
nor
|
|
.BR PTHREAD_CREATE_DETACHED .
|
|
.\"
|
|
.\" ----------------
|
|
.SH "SEE ALSO"
|
|
pthread_create(3P), pthread_detach(3P), sysconf(3C).
|
|
.\"
|
|
.\" ----------------
|
|
.SH NOTES
|
|
The minimum stack size can be retrieved using
|
|
.IR sysconf (3C)
|
|
using the
|
|
.B THREAD_STACK_MIN
|
|
option.
|