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 *restrict attr,
14                                     size_t *restrict 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       └────────────────────────────────────────────┴───────────────┴─────────┘
56

CONFORMING TO

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

NOTES

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

BUGS

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

EXAMPLES

78       See pthread_create(3).
79

SEE ALSO

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

COLOPHON

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