1PTHREAD_ATTR_SETSTACKSIZE(3)Linux Programmer's ManuaPlTHREAD_ATTR_SETSTACKSIZE(3)
2
3
4

NAME

6       pthread_attr_setstacksize,  pthread_attr_getstacksize  -  set/get stack
7       size attribute in thread attributes object
8

SYNOPSIS

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,
14                                     size_t *stacksize);
15
16       Compile and link with -pthread.
17

DESCRIPTION

19       The pthread_attr_setstacksize() function sets the stack size  attribute
20       of the thread attributes object referred to by attr to the value speci‐
21       fied in stacksize.
22
23       The stack size attribute determines the minimum size  (in  bytes)  that
24       will  be  allocated for threads created using the thread attributes ob‐
25       ject attr.
26
27       The pthread_attr_getstacksize() function returns the stack size  attri‐
28       bute  of the thread attributes object referred to by attr in the buffer
29       pointed to by stacksize.
30

RETURN VALUE

32       On success, these functions return 0; on error, they return  a  nonzero
33       error number.
34

ERRORS

36       pthread_attr_setstacksize() can fail with the following error:
37
38       EINVAL The stack size is less than PTHREAD_STACK_MIN (16384) bytes.
39
40       On  some  systems,  pthread_attr_setstacksize() can fail with the error
41       EINVAL if stacksize is not a multiple of the system page size.
42

VERSIONS

44       These functions are provided by glibc since version 2.1.
45

ATTRIBUTES

47       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
48       tributes(7).
49
50       ┌─────────────────────────────┬───────────────┬─────────┐
51Interface                    Attribute     Value   
52       ├─────────────────────────────┼───────────────┼─────────┤
53pthread_attr_setstacksize(), │ Thread safety │ MT-Safe │
54pthread_attr_getstacksize()  │               │         │
55       └─────────────────────────────┴───────────────┴─────────┘

CONFORMING TO

57       POSIX.1-2001, POSIX.1-2008.
58

NOTES

60       For details on the default stack size of new threads, see  pthread_cre‐
61       ate(3).
62
63       A  thread's  stack  size is fixed at the time of thread creation.  Only
64       the main thread can dynamically grow its stack.
65
66       The pthread_attr_setstack(3) function allows an application to set both
67       the size and location of a caller-allocated stack that is to be used by
68       a thread.
69

BUGS

71       As at glibc 2.8, if the  specified  stacksize  is  not  a  multiple  of
72       STACK_ALIGN  (16  bytes on most architectures), it may be rounded down‐
73       ward, in violation of POSIX.1, which says that the allocated stack will
74       be at least stacksize bytes.
75

EXAMPLES

77       See pthread_create(3).
78

SEE ALSO

80       getrlimit(2),    pthread_attr_init(3),    pthread_attr_setguardsize(3),
81       pthread_attr_setstack(3), pthread_create(3), pthreads(7)
82

COLOPHON

84       This page is part of release 5.10 of the Linux  man-pages  project.   A
85       description  of  the project, information about reporting bugs, and the
86       latest    version    of    this    page,    can     be     found     at
87       https://www.kernel.org/doc/man-pages/.
88
89
90
91Linux                             2020-06-09      PTHREAD_ATTR_SETSTACKSIZE(3)
Impressum