1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\" <mtk.manpages@gmail.com>
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .TH PTHREAD_ATTR_SETSTACKSIZE 3 2021-03-22 "Linux" "Linux Programmer's Manual"
8 pthread_attr_setstacksize, pthread_attr_getstacksize \- set/get stack size
9 attribute in thread attributes object
12 .RI ( libpthread ", " \-lpthread )
15 .B #include <pthread.h>
17 .BI "int pthread_attr_setstacksize(pthread_attr_t *" attr \
18 ", size_t " stacksize );
19 .BI "int pthread_attr_getstacksize(const pthread_attr_t *restrict " attr ,
20 .BI " size_t *restrict " stacksize );
24 .BR pthread_attr_setstacksize ()
25 function sets the stack size attribute of the
26 thread attributes object referred to by
28 to the value specified in
31 The stack size attribute determines the minimum size (in bytes) that
32 will be allocated for threads created using the thread attributes object
36 .BR pthread_attr_getstacksize ()
37 function returns the stack size attribute of the
38 thread attributes object referred to by
40 in the buffer pointed to by
43 On success, these functions return 0;
44 on error, they return a nonzero error number.
46 .BR pthread_attr_setstacksize ()
47 can fail with the following error:
50 The stack size is less than
56 .BR pthread_attr_setstacksize ()
57 can fail with the error
61 is not a multiple of the system page size.
63 These functions are provided by glibc since version 2.1.
65 For an explanation of the terms used in this section, see
73 Interface Attribute Value
75 .BR pthread_attr_setstacksize (),
76 .BR pthread_attr_getstacksize ()
77 T} Thread safety MT-Safe
83 POSIX.1-2001, POSIX.1-2008.
85 For details on the default stack size of new threads, see
86 .BR pthread_create (3).
88 A thread's stack size is fixed at the time of thread creation.
89 Only the main thread can dynamically grow its stack.
92 .BR pthread_attr_setstack (3)
93 function allows an application to set both the size and location
94 of a caller-allocated stack that is to be used by a thread.
101 (16 bytes on most architectures), it may be rounded
103 in violation of POSIX.1, which says that the allocated stack will
109 .BR pthread_create (3).
112 .BR pthread_attr_init (3),
113 .BR pthread_attr_setguardsize (3),
114 .BR pthread_attr_setstack (3),
115 .BR pthread_create (3),