1PTHREAD_ATTR_GETSTACK(P)   POSIX Programmer's Manual  PTHREAD_ATTR_GETSTACK(P)
2
3
4

NAME

6       pthread_attr_getstack,   pthread_attr_setstack  -  get  and  set  stack
7       attributes
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_attr_getstack(const pthread_attr_t *restrict attr,
13              void **restrict stackaddr, size_t *restrict stacksize);
14       int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr,
15              size_t stacksize);
16
17
18
19

DESCRIPTION

21       The  pthread_attr_getstack()  and  pthread_attr_setstack()   functions,
22       respectively,  shall  get  and set the thread creation stack attributes
23       stackaddr and stacksize in the attr object.
24
25       The stack attributes specify the area of storage to  be  used  for  the
26       created thread's stack. The base (lowest addressable byte) of the stor‐
27       age shall be stackaddr, and the size of the storage shall be  stacksize
28       bytes.  The stacksize shall be at least {PTHREAD_STACK_MIN}. The stack‐
29       addr shall be aligned appropriately to be used as a stack; for example,
30       pthread_attr_setstack() may fail with [EINVAL] if ( stackaddr & 0x7) is
31       not 0. All pages within the stack described by stackaddr and  stacksize
32       shall be both readable and writable by the thread.
33

RETURN VALUE

35       Upon  successful completion, these functions shall return a value of 0;
36       otherwise, an error number shall be returned to indicate the error.
37
38       The pthread_attr_getstack() function shall store  the  stack  attribute
39       values in stackaddr and stacksize if successful.
40

ERRORS

42       The pthread_attr_setstack() function shall fail if:
43
44       EINVAL The  value  of  stacksize  is  less  than {PTHREAD_STACK_MIN} or
45              exceeds an implementation-defined limit.
46
47
48       The pthread_attr_setstack() function may fail if:
49
50       EINVAL The value of stackaddr does not have proper alignment to be used
51              as  a  stack, or if ( stackaddr + stacksize) lacks proper align‐
52              ment.
53
54       EACCES The stack page(s) described by stackaddr and stacksize  are  not
55              both readable and writable by the thread.
56
57
58       These functions shall not return an error code of [EINTR].
59
60       The following sections are informative.
61

EXAMPLES

63       None.
64

APPLICATION USAGE

66       These  functions are appropriate for use by applications in an environ‐
67       ment where the stack for a thread must be  placed  in  some  particular
68       region of memory.
69
70       While  it might seem that an application could detect stack overflow by
71       providing a protected page outside the  specified  stack  region,  this
72       cannot be done portably. Implementations are free to place the thread's
73       initial stack pointer anywhere within the specified region to  accommo‐
74       date  the machine's stack pointer behavior and allocation requirements.
75       Furthermore, on some architectures, such as the IA-64, "overflow" might
76       mean  that two separate stack pointers allocated within the region will
77       overlap somewhere in the middle of the region.
78

RATIONALE

80       None.
81

FUTURE DIRECTIONS

83       None.
84

SEE ALSO

86       pthread_attr_init() , pthread_attr_setdetachstate() , pthread_attr_set‐
87       stacksize()  ,  pthread_create()  ,  the  Base  Definitions  volume  of
88       IEEE Std 1003.1-2001, <limits.h>, <pthread.h>
89
91       Portions of this text are reprinted and reproduced in  electronic  form
92       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
93       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
94       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
95       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
96       event of any discrepancy between this version and the original IEEE and
97       The Open Group Standard, the original IEEE and The Open Group  Standard
98       is  the  referee document. The original Standard can be obtained online
99       at http://www.opengroup.org/unix/online.html .
100
101
102
103IEEE/The Open Group                  2003             PTHREAD_ATTR_GETSTACK(P)
Impressum