Files
oldlinux-files/Ref-docs/POSIX/susv3/functions/pthread_attr_getstack.html
2024-02-19 00:21:47 -05:00

162 lines
6.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>pthread_attr_getstack</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="pthread_attr_getstack"></a> <a name="tag_03_494"></a><!-- pthread_attr_getstack -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_03_494_01"></a>NAME</h4>
<blockquote>pthread_attr_getstack, pthread_attr_setstack - get and set stack attributes</blockquote>
<h4><a name="tag_03_494_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<div class="box"><code><tt><sup>[<a href="javascript:open_code('THR')">THR</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> #include &lt;<a href="../basedefs/pthread.h.html">pthread.h</a>&gt;<br>
<br>
<tt><sup>[<a href="javascript:open_code('TSA TSS')">TSA TSS</a>]</sup> <img src="../images/opt-start.gif" alt=
"[Option Start]" border="0"> int pthread_attr_getstack(const pthread_attr_t *restrict</tt> <i>attr</i><tt>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; void **restrict</tt> <i>stackaddr</i><tt>, size_t *restrict</tt> <i>stacksize</i><tt>);<br>
int pthread_attr_setstack(pthread_attr_t *</tt><i>attr</i><tt>, void *</tt><i>stackaddr</i><tt>,<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; size_t</tt> <i>stacksize</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]"
border="0"></tt>
<br>
<img src="../images/opt-end.gif" alt="[Option End]" border="0"></tt>
</code></div>
<tt><br>
</tt></blockquote>
<h4><a name="tag_03_494_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>pthread_attr_getstack</i>() and <i>pthread_attr_setstack</i>() functions, respectively, shall get and set the thread
creation stack attributes <i>stackaddr</i> and <i>stacksize</i> in the <i>attr</i> object.</p>
<p>The stack attributes specify the area of storage to be used for the created thread's stack. The base (lowest addressable byte)
of the storage shall be <i>stackaddr</i>, and the size of the storage shall be <i>stacksize</i> bytes. The <i>stacksize</i> shall
be at least {PTHREAD_STACK_MIN}. The <i>stackaddr</i> shall be aligned appropriately to be used as a stack; for example,
<i>pthread_attr_setstack</i>() may fail with [EINVAL] if ( <i>stackaddr</i> &amp; 0x7) is not 0. All pages within the stack
described by <i>stackaddr</i> and <i>stacksize</i> shall be both readable and writable by the thread.</p>
</blockquote>
<h4><a name="tag_03_494_04"></a>RETURN VALUE</h4>
<blockquote>
<p>Upon successful completion, these functions shall return a value of 0; otherwise, an error number shall be returned to indicate
the error.</p>
<p>The <i>pthread_attr_getstack</i>() function shall store the stack attribute values in <i>stackaddr</i> and <i>stacksize</i> if
successful.</p>
</blockquote>
<h4><a name="tag_03_494_05"></a>ERRORS</h4>
<blockquote>
<p>The <i>pthread_attr_setstack</i>() function shall fail if:</p>
<dl compact>
<dt>[EINVAL]</dt>
<dd>The value of <i>stacksize</i> is less than {PTHREAD_STACK_MIN} or exceeds an implementation-defined limit.</dd>
</dl>
<p>The <i>pthread_attr_setstack</i>() function may fail if:</p>
<dl compact>
<dt>[EINVAL]</dt>
<dd>The value of <i>stackaddr</i> does not have proper alignment to be used as a stack, or if ( <i>stackaddr</i> +
<i>stacksize</i>) lacks proper alignment.</dd>
<dt>[EACCES]</dt>
<dd>The stack page(s) described by <i>stackaddr</i> and <i>stacksize</i> are not both readable and writable by the thread.</dd>
</dl>
<p>These functions shall not return an error code of [EINTR].</p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_03_494_06"></a>EXAMPLES</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_494_07"></a>APPLICATION USAGE</h4>
<blockquote>
<p>These functions are appropriate for use by applications in an environment where the stack for a thread must be placed in some
particular region of memory.</p>
<p>While it might seem that an application could detect stack overflow by providing a protected page outside the specified stack
region, this cannot be done portably. Implementations are free to place the thread's initial stack pointer anywhere within the
specified region to accommodate the machine's stack pointer behavior and allocation requirements. Furthermore, on some
architectures, such as the IA-64, &quot;overflow&quot; might mean that two separate stack pointers allocated within the region will overlap
somewhere in the middle of the region.</p>
</blockquote>
<h4><a name="tag_03_494_08"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_494_09"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_03_494_10"></a>SEE ALSO</h4>
<blockquote>
<p><a href="pthread_attr_init.html"><i>pthread_attr_init</i>()</a> , <a href=
"pthread_attr_setdetachstate.html"><i>pthread_attr_setdetachstate</i>()</a> , <a href=
"pthread_attr_setstacksize.html"><i>pthread_attr_setstacksize</i>()</a> , <a href="pthread_create.html"><i>pthread_create</i>()</a>
, the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/limits.h.html"><i>&lt;limits.h&gt;</i></a>,
<a href="../basedefs/pthread.h.html"><i>&lt;pthread.h&gt;</i></a></p>
</blockquote>
<h4><a name="tag_03_494_11"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 6. Developed as an XSI extension and brought into the BASE by IEEE PASC Interpretation 1003.1 #101.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>