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(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  non-zero
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

CONFORMING TO

46       POSIX.1-2001.
47

EXAMPLE

49       See pthread_create(3).
50

NOTES

52       For details on the default stack size of new threads, see  pthread_cre‐
53       ate(3).
54
55       A  thread's  stack  size is fixed at the time of thread creation.  Only
56       the main thread can dynamically grow its stack.
57
58       The pthread_attr_setstack(3) function allows an application to set both
59       the size and location of a caller-allocated stack that is to be used by
60       a thread.
61

BUGS

63       As at glibc 2.8, if the  specified  stacksize  is  not  a  multiple  of
64       STACK_ALIGN  (16  bytes on most architectures), it may be rounded down‐
65       wards, in violation of POSIX.1-2001,  which  says  that  the  allocated
66       stack will be at least stacksize bytes.
67

SEE ALSO

69       getrlimit(2),    pthread_attr_init(3),    pthread_attr_setguardsize(3),
70       pthread_attr_setstack(3), pthread_create(3), pthreads(7)
71

COLOPHON

73       This page is part of release 3.22 of the Linux  man-pages  project.   A
74       description  of  the project, and information about reporting bugs, can
75       be found at http://www.kernel.org/doc/man-pages/.
76
77
78
79Linux                             2008-11-05      PTHREAD_ATTR_SETSTACKSIZE(3)
Impressum