1PTHREAD_ATTR_SETSTACKSIZE(3)Linux Programmer's ManuaPlTHREAD_ATTR_SETSTACKSIZE(3)
2
3
4
6 pthread_attr_setstacksize, pthread_attr_getstacksize - set/get stack
7 size attribute in thread attributes object
8
10 #include <pthread.h>
11
12 int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
13 int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize);
14
15 Compile and link with -pthread.
16
18 The pthread_attr_setstacksize() function sets the stack size attribute
19 of the thread attributes object referred to by attr to the value speci‐
20 fied in stacksize.
21
22 The stack size attribute determines the minimum size (in bytes) that
23 will be allocated for threads created using the thread attributes
24 object attr.
25
26 The pthread_attr_getstacksize() function returns the stack size
27 attribute of the thread attributes object referred to by attr in the
28 buffer pointed to by stacksize.
29
31 On success, these functions return 0; on error, they return a nonzero
32 error number.
33
35 pthread_attr_setstacksize() can fail with the following error:
36
37 EINVAL The stack size is less than PTHREAD_STACK_MIN (16384) bytes.
38
39 On some systems, pthread_attr_setstacksize() can fail with the error
40 EINVAL if stacksize is not a multiple of the system page size.
41
43 These functions are provided by glibc since version 2.1.
44
46 For an explanation of the terms used in this section, see
47 attributes(7).
48
49 ┌─────────────────────────────┬───────────────┬─────────┐
50 │Interface │ Attribute │ Value │
51 ├─────────────────────────────┼───────────────┼─────────┤
52 │pthread_attr_setstacksize(), │ Thread safety │ MT-Safe │
53 │pthread_attr_getstacksize() │ │ │
54 └─────────────────────────────┴───────────────┴─────────┘
56 POSIX.1-2001, POSIX.1-2008.
57
59 For details on the default stack size of new threads, see pthread_cre‐
60 ate(3).
61
62 A thread's stack size is fixed at the time of thread creation. Only
63 the main thread can dynamically grow its stack.
64
65 The pthread_attr_setstack(3) function allows an application to set both
66 the size and location of a caller-allocated stack that is to be used by
67 a thread.
68
70 As at glibc 2.8, if the specified stacksize is not a multiple of
71 STACK_ALIGN (16 bytes on most architectures), it may be rounded down‐
72 ward, in violation of POSIX.1, which says that the allocated stack will
73 be at least stacksize bytes.
74
76 See pthread_create(3).
77
79 getrlimit(2), pthread_attr_init(3), pthread_attr_setguardsize(3),
80 pthread_attr_setstack(3), pthread_create(3), pthreads(7)
81
83 This page is part of release 4.15 of the Linux man-pages project. A
84 description of the project, information about reporting bugs, and the
85 latest version of this page, can be found at
86 https://www.kernel.org/doc/man-pages/.
87
88
89
90Linux 2017-09-15 PTHREAD_ATTR_SETSTACKSIZE(3)