128 lines
3.0 KiB
Plaintext
128 lines
3.0 KiB
Plaintext
'\"macro stdmacro
|
|
.\"
|
|
.\" ----------------
|
|
.TH pthread_attr_setguardsize 3P
|
|
.\"
|
|
.\" ----------------
|
|
.SH NAME
|
|
pthread_attr_setguardsize,
|
|
pthread_attr_getguardsize
|
|
\- get or set the thread guardsize attribute
|
|
.\"
|
|
.\" ----------------
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
.nf
|
|
.ft 3
|
|
#include <pthread.h>
|
|
.HP
|
|
.ft 3
|
|
int pthread_attr_setguardsize(pthread_attr_t \(**attr, size_t guardsize);
|
|
.HP
|
|
.ft 3
|
|
int pthread_attr_getguardsize(const pthread_attr_t \(**attr,
|
|
.br
|
|
size_t \(**oguardsize);
|
|
.ft 1
|
|
.fi
|
|
.Op
|
|
.\"
|
|
.\" ----------------
|
|
.SH DESCRIPTION
|
|
The guardsize attribute controls the size of the guard area for
|
|
the created thread's stack.
|
|
The guardsize
|
|
attribute provides protection against overflow of the stack pointer.
|
|
If a thread's stack is created with guard protection,
|
|
the implementation allocates extra memory at the overflow
|
|
end of the stack as a buffer against stack overflow of the
|
|
stack pointer.
|
|
If an application overflows into this buffer an error results
|
|
(possibly in a
|
|
.B SIGSEGV
|
|
signal being delivered to the thread).
|
|
.\"
|
|
.PP
|
|
The guardsize attribute is provided to the application for two reasons:
|
|
.IP 1.
|
|
Overflow protection can potentially result in wasted system resources.
|
|
An application that creates a large number of threads, and which knows
|
|
its threads will never overflow their stack, can save system resources
|
|
by turning off guard areas.
|
|
.IP 2.
|
|
When threads allocate large data structures on the stack, large guard
|
|
areas may be needed to detect stack overflow.
|
|
.\"
|
|
.PP
|
|
The
|
|
.IR pthread_attr_getguardsize ()
|
|
function gets the guardsize attribute in the
|
|
.I attr
|
|
object.
|
|
This attribute is returned in the
|
|
.I oguardsize
|
|
parameter.
|
|
.\"
|
|
.PP
|
|
The
|
|
.IR pthread_attr_setguardsize ()
|
|
function sets the guardsize attribute in the
|
|
.I attr
|
|
object.
|
|
The new value of this attribute is obtained from the
|
|
.I guardsize
|
|
parameter.
|
|
If
|
|
.I guardsize
|
|
is zero, a guard area will not be provided for threads created with
|
|
.IR attr .
|
|
If
|
|
.I guardsize
|
|
is greater than zero, a guard area of at least size
|
|
.I guardsize
|
|
bytes is provided for each thread created with
|
|
.IR attr .
|
|
.\"
|
|
.PP
|
|
IRIX rounds up the value of
|
|
.I guardsize
|
|
to a multiple of the configurable system variable
|
|
.B PAGESIZE
|
|
(see \f4<sys/mman.h>\fP).
|
|
However,
|
|
.IR pthread_attr_getguardsize ()
|
|
will return the guard size specified by the previous call to
|
|
.IR pthread_attr_setguardsize ().
|
|
.\"
|
|
.PP
|
|
The default value of the
|
|
.I guardsize
|
|
attribute is
|
|
.B PAGESIZE
|
|
bytes.
|
|
The actual value of
|
|
.B PAGESIZE
|
|
is system-dependent and may vary.
|
|
.\"
|
|
.PP
|
|
If the
|
|
.I stackaddr
|
|
attribute has been set (that is, the caller is allocating and
|
|
managing its own thread stacks), the guardsize
|
|
attribute is ignored and no protection will be provided by the
|
|
implementation.
|
|
It is the responsibility of the application to manage stack
|
|
overflow along with stack allocation and management in this case.
|
|
.\"
|
|
.SH DIAGNOSTICS
|
|
The functions
|
|
.IR pthread_attr_getguardsize ()
|
|
and
|
|
.IR pthread_attr_setguardsize ()
|
|
always return zero.
|
|
.\"
|
|
.\" ----------------
|
|
.SH "SEE ALSO"
|
|
pthread_attr_init(3P),
|
|
pthread_create(3P).
|