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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

VERSIONS

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

ATTRIBUTES

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

CONFORMING TO

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

NOTES

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

BUGS

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

EXAMPLE

76       See pthread_create(3).
77

SEE ALSO

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

COLOPHON

83       This page is part of release 5.02 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)
Impressum