~ubuntu-branches/ubuntu/maverick/manpages-posix/maverick

1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
2
.TH "PTHREAD_GETSPECIFIC" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
3
.\" pthread_getspecific 
4
.SH NAME
5
pthread_getspecific, pthread_setspecific \- thread-specific data management
6
.SH SYNOPSIS
7
.LP
8
\fB#include <pthread.h>
9
.br
10
.sp
11
void *pthread_getspecific(pthread_key_t\fP \fIkey\fP\fB);
12
.br
13
int pthread_setspecific(pthread_key_t\fP \fIkey\fP\fB, const void
14
*\fP\fIvalue\fP\fB); \fP
15
\fB
16
.br
17
\fP
18
.SH DESCRIPTION
19
.LP
20
The \fIpthread_getspecific\fP() function shall return the value currently
21
bound to the specified \fIkey\fP on behalf of the
22
calling thread.
23
.LP
24
The \fIpthread_setspecific\fP() function shall associate a thread-specific
25
\fIvalue\fP with a \fIkey\fP obtained via a
26
previous call to \fIpthread_key_create\fP(). Different threads may
27
bind
28
different values to the same key. These values are typically pointers
29
to blocks of dynamically allocated memory that have been
30
reserved for use by the calling thread.
31
.LP
32
The effect of calling \fIpthread_getspecific\fP() or \fIpthread_setspecific\fP()
33
with a \fIkey\fP value not obtained from \fIpthread_key_create\fP()
34
or after \fIkey\fP has been deleted with \fIpthread_key_delete\fP()
35
is undefined.
36
.LP
37
Both \fIpthread_getspecific\fP() and \fIpthread_setspecific\fP() may
38
be called from a thread-specific data destructor
39
function. A call to \fIpthread_getspecific\fP() for the thread-specific
40
data key being destroyed shall return the value NULL,
41
unless the value is changed (after the destructor starts) by a call
42
to \fIpthread_setspecific\fP(). Calling
43
\fIpthread_setspecific\fP() from a thread-specific data destructor
44
routine may result either in lost storage (after at least
45
PTHREAD_DESTRUCTOR_ITERATIONS attempts at destruction) or in an infinite
46
loop.
47
.LP
48
Both functions may be implemented as macros.
49
.SH RETURN VALUE
50
.LP
51
The \fIpthread_getspecific\fP() function shall return the thread-specific
52
data value associated with the given \fIkey\fP. If
53
no thread-specific data value is associated with \fIkey\fP, then the
54
value NULL shall be returned.
55
.LP
56
If successful, the \fIpthread_setspecific\fP() function shall return
57
zero; otherwise, an error number shall be returned to
58
indicate the error.
59
.SH ERRORS
60
.LP
61
No errors are returned from \fIpthread_getspecific\fP().
62
.LP
63
The \fIpthread_setspecific\fP() function shall fail if:
64
.TP 7
65
.B ENOMEM
66
Insufficient memory exists to associate the value with the key.
67
.sp
68
.LP
69
The \fIpthread_setspecific\fP() function may fail if:
70
.TP 7
71
.B EINVAL
72
The key value is invalid.
73
.sp
74
.LP
75
These functions shall not return an error code of [EINTR].
76
.LP
77
\fIThe following sections are informative.\fP
78
.SH EXAMPLES
79
.LP
80
None.
81
.SH APPLICATION USAGE
82
.LP
83
None.
84
.SH RATIONALE
85
.LP
86
Performance and ease-of-use of \fIpthread_getspecific\fP() are critical
87
for functions that rely on maintaining state in
88
thread-specific data. Since no errors are required to be detected
89
by it, and since the only error that could be detected is the use
90
of an invalid key, the function to \fIpthread_getspecific\fP() has
91
been designed to favor speed and simplicity over error
92
reporting.
93
.SH FUTURE DIRECTIONS
94
.LP
95
None.
96
.SH SEE ALSO
97
.LP
98
\fIpthread_key_create\fP() , the Base Definitions volume of
99
IEEE\ Std\ 1003.1-2001, \fI<pthread.h>\fP
100
.SH COPYRIGHT
101
Portions of this text are reprinted and reproduced in electronic form
102
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
103
-- Portable Operating System Interface (POSIX), The Open Group Base
104
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
105
Electrical and Electronics Engineers, Inc and The Open Group. In the
106
event of any discrepancy between this version and the original IEEE and
107
The Open Group Standard, the original IEEE and The Open Group Standard
108
is the referee document. The original Standard can be obtained online at
109
http://www.opengroup.org/unix/online.html .