PTHREAD_GETSPECIFIC(3) BSD Library Functions Manual PTHREAD_GETSPECIFIC(3)NAME
pthread_getspecific -- get a thread-specific data value
SYNOPSIS
#include <pthread.h>
void *
pthread_getspecific(pthread_key_t key);
DESCRIPTION
The pthread_getspecific() function returns the value that is currently bound to the specified key, on behalf of the calling thread.
The effect of calling pthread_getspecific() with a key value that was not obtained from pthread_key_create(), or after a key has been deleted
with pthread_key_delete(), is undefined.
pthread_getspecific() may be called from a thread-specific data destructor function.
RETURN VALUES
The pthread_getspecific() function will return the thread-specific data value associated with the given key. If no thread-specific data
value is associated with key, the value NULL is returned.
ERRORS
None.
SEE ALSO pthread_key_create(3), pthread_key_delete(3), pthread_setspecific(3)STANDARDS
pthread_getspecific() conforms to ISO/IEC 9945-1:1996 (``POSIX.1'').
BSD April 4, 1996 BSD
Check Out this Related Man Page
pthread_getspecific(3C)pthread_getspecific(3C)NAME
pthread_getspecific, pthread_setspecific - manage thread-specific data
SYNOPSIS
cc -mt [ flag... ] file... -lpthread [ library... ]
#include <pthread.h>
int pthread_setspecific(pthread_key_t key, const void *value);
void *pthread_getspecific(pthread_key_t key);
The pthread_setspecific() function associates a thread-specific value with a key obtained by way of a previous call to pthread_key_cre-
ate(). Different threads may bind different values to the same key. These values are typically pointers to blocks of dynamically allocated
memory that have been reserved for use by the calling thread.
The pthread_getspecific() function returns the value currently bound to the specified key on behalf of the calling thread.
The effect of calling pthread_setspecific() or pthread_getspecific() with a key value not obtained from pthread_key_create() or after key
has been deleted with pthread_key_delete() is undefined.
Both pthread_setspecific() and pthread_getspecific() may be called from a thread-specific data destructor function. However, calling
pthread_setspecific() from a destructor may result in lost storage or infinite loops.
The pthread_getspecific() function returns the thread-specific data value associated with the given key. If no thread-specific data value
is associated with key, then the value NULL is returned.
Upon successful completion, the pthread_setspecific() function returns 0. Otherwise, an error number is returned to indicate the error.
The pthread_setspecific() function will fail if:
ENOMEM Insufficient memory exists to associate the value with the key.
The pthread_setspecific() function may fail if:
EINVAL The key value is invalid.
The pthread_getspecific() function does not return errors.
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Interface Stability |Standard |
+-----------------------------+-----------------------------+
|MT-Level |MT-Safe |
+-----------------------------+-----------------------------+
pthread_key_create(3C)attributes(5), standards(5)
23 Mar 2005 pthread_getspecific(3C)
i am trying to compile and install free qt for x11 2.2.4 in order to use kde 2.1. i'm using freebsd 4.3
i currently have XFree86 installed and working.
i followed these instructions:
ftp://ftp.trolltech.com/qt/source/INSTALL
i get through the unpacking fine and i set my .profile.
--... (2 Replies)
Can anyone explain me how to use pthread_key_create() , pthread_setspecific(), pthread_getspecific() and pthread_key_delete () routines in pthreads.
Kindly state by an example. (3 Replies)
I have a problem with a C multi-threaded program I am writing. I cannot figure out how to keep the unique key value at the thread level. I wrote a program in C that forked a bunch of processes and then decided to convert it to threads and I can't keep the key unique to each thread. In a nutshell... (3 Replies)
I want to build a little website on a Sun Blade 100 running Solaris 10.
I just went out to apache.org and downloaded Unix Source: httpd-2.2.8.tar.gz
After unpacking the tarball, I CD'd into the subdirectory and ran the configure utility. Of course, it crapped out. I see that it is... (17 Replies)
Hi all,
Is anyone aware of what operations are involved when a call to pthread_self() is made, obtaining the unique thread ID on a Ubuntu system (or even any Linux flavour)?
Specifically, to retrieve the thread id, is there any locking required or atomic operations?
I'm building an... (11 Replies)
I'm new to GTK development, so I've been going through the examples just to capture the basics. I've done a lot of Unix GUI development before, but it was all Xt/Motif stuff. So, the GTK scheduler is something new to me.
That said, I was going through the color selection example here, and was... (8 Replies)
Hi guys ,
i got segment fault , and when i trace , found it happens since the value of pointer which is returned by Struct S_client (*ptr) is zero
if (ptr !=0)i know , adding above line of code is not the solution and not correct for the case since above line only check for the pointer... (1 Reply)
Hi
We meet errors while running configuration scripts to prepare compiling source code on AIX 7.2. This error does not happen on AIX5.3 and AIX6.1
With the “/usr/bin/sh” from AIX7.2, sometimes , the script runs sucessfully, sometimes not. It’s unstable, and I don’t know why.
When... (10 Replies)