1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
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.
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.
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
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
26 .TH PTHREAD_ATTR_SETSTACKSIZE 3 2021-03-22 "Linux" "Linux Programmer's Manual"
28 pthread_attr_setstacksize, pthread_attr_getstacksize \- set/get stack size
29 attribute in thread attributes object
32 .B #include <pthread.h>
34 .BI "int pthread_attr_setstacksize(pthread_attr_t *" attr \
35 ", size_t " stacksize );
36 .BI "int pthread_attr_getstacksize(const pthread_attr_t *restrict " attr ,
37 .BI " size_t *restrict " stacksize );
39 Compile and link with \fI\-pthread\fP.
43 .BR pthread_attr_setstacksize ()
44 function sets the stack size attribute of the
45 thread attributes object referred to by
47 to the value specified in
50 The stack size attribute determines the minimum size (in bytes) that
51 will be allocated for threads created using the thread attributes object
55 .BR pthread_attr_getstacksize ()
56 function returns the stack size attribute of the
57 thread attributes object referred to by
59 in the buffer pointed to by
62 On success, these functions return 0;
63 on error, they return a nonzero error number.
65 .BR pthread_attr_setstacksize ()
66 can fail with the following error:
69 The stack size is less than
75 .BR pthread_attr_setstacksize ()
76 can fail with the error
80 is not a multiple of the system page size.
82 These functions are provided by glibc since version 2.1.
84 For an explanation of the terms used in this section, see
92 Interface Attribute Value
94 .BR pthread_attr_setstacksize (),
95 .BR pthread_attr_getstacksize ()
96 T} Thread safety MT-Safe
102 POSIX.1-2001, POSIX.1-2008.
104 For details on the default stack size of new threads, see
105 .BR pthread_create (3).
107 A thread's stack size is fixed at the time of thread creation.
108 Only the main thread can dynamically grow its stack.
111 .BR pthread_attr_setstack (3)
112 function allows an application to set both the size and location
113 of a caller-allocated stack that is to be used by a thread.
120 (16 bytes on most architectures), it may be rounded
122 in violation of POSIX.1, which says that the allocated stack will
128 .BR pthread_create (3).
131 .BR pthread_attr_init (3),
132 .BR pthread_attr_setguardsize (3),
133 .BR pthread_attr_setstack (3),
134 .BR pthread_create (3),