8999 SMBIOS: cleanup 32-bit specific code
[unleashed.git] / usr / src / man / man3c / pthread_attr_getguardsize.3c
blob0b9e6570303e2af59bfb91fb6414b5af08378881
1 '\" te
2 .\" Copyright (c) 2008, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Copyright (c) 2001, the Institute of Electrical and Electronics Engineers, Inc. and The Open Group. All Rights Reserved.
4 .\" Copyright 1991, 1992, 1994, The X/Open Company Ltd.
5 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
6 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
8 .\"  This notice shall appear on any product containing this material.
9 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
10 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
11 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
12 .TH PTHREAD_ATTR_GETGUARDSIZE 3C "Mar 23, 2005"
13 .SH NAME
14 pthread_attr_getguardsize, pthread_attr_setguardsize \- get or set thread
15 guardsize attribute
16 .SH SYNOPSIS
17 .LP
18 .nf
19 cc -mt [ \fIflag\fR... ] \fIfile\fR... -lpthread [ \fIlibrary\fR... ]
20 #include <pthread.h>
22 \fBint\fR \fBpthread_attr_getguardsize\fR(\fBconst pthread_attr_t *restrict\fR \fIattr\fR,
23      \fBsize_t *restrict\fR \fIguardsize\fR);
24 .fi
26 .LP
27 .nf
28 \fBint\fR \fBpthread_attr_setguardsize\fR(\fBpthread_attr_t *\fR\fIattr\fR, \fBsize_t\fR \fIguardsize\fR);
29 .fi
31 .SH DESCRIPTION
32 .sp
33 .LP
34 The \fIguardsize\fR attribute controls the size of the guard area for the
35 created thread's stack. The \fIguardsize\fR attribute provides protection
36 against overflow of the stack pointer. If a thread's stack is created with
37 guard protection, the implementation allocates extra memory at the overflow end
38 of the stack as a buffer against stack overflow of the stack pointer. If an
39 application overflows into this buffer an error results (possibly in a
40 \fBSIGSEGV\fR signal being delivered to the thread).
41 .sp
42 .LP
43 The \fIguardsize\fR attribute is provided to the application for two reasons:
44 .RS +4
45 .TP
47 Overflow protection can potentially result in wasted system resources. An
48 application that creates a large number of threads, and which knows its threads
49 will never overflow their stack, can save system resources by turning off guard
50 areas.
51 .RE
52 .RS +4
53 .TP
55 When threads allocate large data structures on the stack, large guard areas
56 may be needed to detect stack overflow.
57 .RE
58 .sp
59 .LP
60 The  \fBpthread_attr_getguardsize()\fR function gets the \fIguardsize\fR
61 attribute in the \fIattr\fR object. This attribute is returned in the
62 \fIguardsize\fR parameter.
63 .sp
64 .LP
65 The  \fBpthread_attr_setguardsize()\fR function sets the \fIguardsize\fR
66 attribute in the \fIattr\fR object. The new value of this attribute is obtained
67 from the \fIguardsize\fR parameter. If \fIguardsize\fR is  \fB0\fR, a guard
68 area will not be provided for threads created with \fIattr\fR. If
69 \fIguardsize\fR is greater than  \fB0\fR, a guard area of at least size
70 \fIguardsize\fR bytes is provided for each thread created with \fIattr\fR.
71 .sp
72 .LP
73 A conforming implementation is permitted to round up the value contained in
74 \fIguardsize\fR to a multiple of the configurable system variable
75 \fBPAGESIZE.\fR If an implementation rounds up the value of \fIguardsize\fR to
76 a multiple of  \fBPAGESIZE,\fR a call to \fBpthread_attr_getguardsize()\fR
77 specifying \fIattr\fR will store in the \fIguardsize\fR parameter the guard
78 size specified by the previous  \fBpthread_attr_setguardsize()\fR function
79 call.
80 .sp
81 .LP
82 The default value of the \fIguardsize\fR attribute is  \fBPAGESIZE\fR bytes.
83 The actual value of  \fBPAGESIZE\fR is implementation-dependent and may not be
84 the same on all implementations.
85 .sp
86 .LP
87 If the \fIstackaddr\fR attribute has been set (that is, the caller is
88 allocating and managing its own thread stacks), the \fIguardsize\fR attribute
89 is ignored and no protection will be provided by the implementation. It is the
90 responsibility of the application to manage stack overflow along with stack
91 allocation and management in this case.
92 .SH RETURN VALUES
93 .sp
94 .LP
95 If successful, the  \fBpthread_attr_getguardsize()\fR and
96 \fBpthread_attr_setguardsize()\fR functions return  \fB0\fR. Otherwise, an
97 error number is returned to indicate the error.
98 .SH ERRORS
99 .sp
101 The \fBpthread_attr_getguardsize()\fR and \fBpthread_attr_setguardsize()\fR
102 functions will fail if:
104 .ne 2
106 \fB\fBEINVAL\fR \fR
108 .RS 11n
109 The attribute \fIattr\fR is invalid.
113 .ne 2
115 \fB\fBEINVAL\fR \fR
117 .RS 11n
118 The parameter \fIguardsize\fR is invalid.
122 .ne 2
124 \fB\fBEINVAL\fR \fR
126 .RS 11n
127 The parameter \fIguardsize\fR contains an invalid value.
130 .SH ATTRIBUTES
133 See \fBattributes\fR(5) for descriptions of the following attributes:
138 box;
139 c | c
140 l | l .
141 ATTRIBUTE TYPE  ATTRIBUTE VALUE
143 Interface Stability     Standard
145 MT-Level        MT-Safe
148 .SH SEE ALSO
151 \fBsysconf\fR(3C), \fBpthread_attr_init\fR(3C), \fBattributes\fR(5),
152 \fBstandards\fR(5)