164 lines
6.8 KiB
HTML
164 lines
6.8 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_key_delete</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="pthread_key_delete"></a> <a name="tag_03_535"></a><!-- pthread_key_delete -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_535_01"></a>NAME</h4>
|
|
|
|
<blockquote>pthread_key_delete - thread-specific data key deletion</blockquote>
|
|
|
|
<h4><a name="tag_03_535_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 <<a href="../basedefs/pthread.h.html">pthread.h</a>><br>
|
|
<br>
|
|
int pthread_key_delete(pthread_key_t</tt> <i>key</i><tt>); <img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_535_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>pthread_key_delete</i>() function shall delete a thread-specific data key previously returned by <a href=
|
|
"../functions/pthread_key_create.html"><i>pthread_key_create</i>()</a>. The thread-specific data values associated with <i>key</i>
|
|
need not be NULL at the time <i>pthread_key_delete</i>() is called. It is the responsibility of the application to free any
|
|
application storage or perform any cleanup actions for data structures related to the deleted key or associated thread-specific
|
|
data in any threads; this cleanup can be done either before or after <i>pthread_key_delete</i>() is called. Any attempt to use
|
|
<i>key</i> following the call to <i>pthread_key_delete</i>() results in undefined behavior.</p>
|
|
|
|
<p>The <i>pthread_key_delete</i>() function shall be callable from within destructor functions. No destructor functions shall be
|
|
invoked by <i>pthread_key_delete</i>(). Any destructor function that may have been associated with <i>key</i> shall no longer be
|
|
called upon thread exit.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>If successful, the <i>pthread_key_delete</i>() function shall return zero; otherwise, an error number shall be returned to
|
|
indicate the error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>pthread_key_delete</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>The <i>key</i> value is invalid.</dd>
|
|
</dl>
|
|
|
|
<p>The <i>pthread_key_delete</i>() function 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_535_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>A thread-specific data key deletion function has been included in order to allow the resources associated with an unused
|
|
thread-specific data key to be freed. Unused thread-specific data keys can arise, among other scenarios, when a dynamically loaded
|
|
module that allocated a key is unloaded.</p>
|
|
|
|
<p>Conforming applications are responsible for performing any cleanup actions needed for data structures associated with the key to
|
|
be deleted, including data referenced by thread-specific data values. No such cleanup is done by <i>pthread_key_delete</i>(). In
|
|
particular, destructor functions are not called. There are several reasons for this division of responsibility:</p>
|
|
|
|
<ol>
|
|
<li>
|
|
<p>The associated destructor functions used to free thread-specific data at thread exit time are only guaranteed to work correctly
|
|
when called in the thread that allocated the thread-specific data. (Destructors themselves may utilize thread-specific data.) Thus,
|
|
they cannot be used to free thread-specific data in other threads at key deletion time. Attempting to have them called by other
|
|
threads at key deletion time would require other threads to be asynchronously interrupted. But since interrupted threads could be
|
|
in an arbitrary state, including holding locks necessary for the destructor to run, this approach would fail. In general, there is
|
|
no safe mechanism whereby an implementation could free thread-specific data at key deletion time.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Even if there were a means of safely freeing thread-specific data associated with keys to be deleted, doing so would require
|
|
that implementations be able to enumerate the threads with non-NULL data and potentially keep them from creating more
|
|
thread-specific data while the key deletion is occurring. This special case could cause extra synchronization in the normal case,
|
|
which would otherwise be unnecessary.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>For an application to know that it is safe to delete a key, it has to know that all the threads that might potentially ever use
|
|
the key do not attempt to use it again. For example, it could know this if all the client threads have called a cleanup procedure
|
|
declaring that they are through with the module that is being shut down, perhaps by setting a reference count to zero.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="pthread_key_create.html"><i>pthread_key_create</i>()</a> , the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/pthread.h.html"><i><pthread.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 5. Included for alignment with the POSIX Threads Extension.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_535_12"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>pthread_key_delete</i>() function is marked as part of the Threads option.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® 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>
|
|
|