1pthread_attr_setstacksize(3)Library Functions Manualpthread_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

LIBRARY

10       POSIX threads library (libpthread, -lpthread)
11

SYNOPSIS

13       #include <pthread.h>
14
15       int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
16       int pthread_attr_getstacksize(const pthread_attr_t *restrict attr,
17                                     size_t *restrict stacksize);
18

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

ATTRIBUTES

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

VERSIONS

56       These functions are provided since glibc 2.1.
57

STANDARDS

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

NOTES

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

BUGS

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

EXAMPLES

79       See pthread_create(3).
80

SEE ALSO

82       getrlimit(2),    pthread_attr_init(3),    pthread_attr_setguardsize(3),
83       pthread_attr_setstack(3), pthread_create(3), pthreads(7)
84
85
86
87Linux man-pages 6.05              2023-07-20      pthread_attr_setstacksize(3)
Impressum