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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       pthread_attr_getstack,  pthread_attr_setstack  -  get  and  set   stack
13       attributes
14

SYNOPSIS

16       #include <pthread.h>
17
18       int pthread_attr_getstack(const pthread_attr_t *restrict attr,
19              void **restrict stackaddr, size_t *restrict stacksize);
20       int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr,
21              size_t stacksize);
22
23
24
25

DESCRIPTION

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

RETURN VALUE

41       Upon successful completion, these functions shall return a value of  0;
42       otherwise, an error number shall be returned to indicate the error.
43
44       The  pthread_attr_getstack()  function  shall store the stack attribute
45       values in stackaddr and stacksize if successful.
46

ERRORS

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

EXAMPLES

69       None.
70

APPLICATION USAGE

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

RATIONALE

86       None.
87

FUTURE DIRECTIONS

89       None.
90

SEE ALSO

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