OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_attr_setstacksize.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
8 .\"
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
13 .\"
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein.  The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
20 .\" professionally.
21 .\"
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
24 .\" %%%LICENSE_END
25 .\"
26 .TH PTHREAD_ATTR_SETSTACKSIZE 3 2014-05-28 "Linux" "Linux Programmer's Manual"
27 .SH NAME
28 pthread_attr_setstacksize, pthread_attr_getstacksize \- set/get stack size
29 attribute in thread attributes object
30 .SH SYNOPSIS
31 .nf
32 .B #include <pthread.h>
33
34 .BI "int pthread_attr_setstacksize(pthread_attr_t *" attr \
35 ", size_t " stacksize );
36 .BI "int pthread_attr_getstacksize(const pthread_attr_t *" attr \
37 ", size_t *" stacksize );
38 .sp
39 Compile and link with \fI\-pthread\fP.
40 .fi
41 .SH DESCRIPTION
42 The
43 .BR pthread_attr_setstacksize ()
44 function sets the stack size attribute of the
45 thread attributes object referred to by
46 .I attr
47 to the value specified in
48 .IR stacksize .
49
50 The stack size attribute determines the minimum size (in bytes) that
51 will be allocated for threads created using the thread attributes object
52 .IR attr .
53
54 The
55 .BR pthread_attr_getstacksize ()
56 function returns the stack size attribute of the
57 thread attributes object referred to by
58 .I attr
59 in the buffer pointed to by
60 .IR stacksize .
61 .SH RETURN VALUE
62 On success, these functions return 0;
63 on error, they return a nonzero error number.
64 .SH ERRORS
65 .BR pthread_attr_setstacksize ()
66 can fail with the following error:
67 .TP
68 .B EINVAL
69 The stack size is less than
70 .BR PTHREAD_STACK_MIN
71 (16384) bytes.
72 .PP
73 On some systems,
74 .\" e.g., MacOS
75 .BR pthread_attr_setstacksize ()
76 can fail with the error
77 .B EINVAL
78 if
79 .I stacksize
80 is not a multiple of the system page size.
81 .SH VERSIONS
82 These functions are provided by glibc since version 2.1.
83 .SH ATTRIBUTES
84 .SS Multithreading (see pthreads(7))
85 The
86 .BR pthread_attr_setstacksize ()
87 and
88 .BR pthread_attr_getstacksize ()
89 functions are thread-safe.
90 .SH CONFORMING TO
91 POSIX.1-2001.
92 .SH NOTES
93 For details on the default stack size of new threads, see
94 .BR pthread_create (3).
95
96 A thread's stack size is fixed at the time of thread creation.
97 Only the main thread can dynamically grow its stack.
98
99 The
100 .BR pthread_attr_setstack (3)
101 function allows an application to set both the size and location
102 of a caller-allocated stack that is to be used by a thread.
103 .SH BUGS
104 As at glibc 2.8,
105 if the specified
106 .I stacksize
107 is not a multiple of
108 .BR STACK_ALIGN
109 (16 bytes on most architectures), it may be rounded
110 .IR downward ,
111 in violation of POSIX.1-2001, which says that the allocated stack will
112 be at least
113 .I stacksize
114 bytes.
115 .SH EXAMPLE
116 See
117 .BR pthread_create (3).
118 .SH SEE ALSO
119 .BR getrlimit (2),
120 .BR pthread_attr_init (3),
121 .BR pthread_attr_setguardsize (3),
122 .BR pthread_attr_setstack (3),
123 .BR pthread_create (3),
124 .BR pthreads (7)
125 .SH COLOPHON
126 This page is part of release 3.79 of the Linux
127 .I man-pages
128 project.
129 A description of the project,
130 information about reporting bugs,
131 and the latest version of this page,
132 can be found at
133 \%http://www.kernel.org/doc/man\-pages/.