Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

pthread_getspecific(3) [mojave man page]

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 currently bound to the specified key on behalf of the calling thread. The effect of calling pthread_getspecific() with a key value not obtained from pthread_key_create() or after key has been deleted with pthread_key_delete() is undefined. The pthread_getspecific() function 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, then the value NULL is returned. ERRORS
None. SEE ALSO
pthread_key_create(3), pthread_key_delete(3), pthread_setspecific(3) STANDARDS
The pthread_getspecific() function conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). BSD
April 4, 1996 BSD

Check Out this Related Man Page

PTHREAD_GETSPECIFIC(3)					   BSD Library Functions Manual 				    PTHREAD_GETSPECIFIC(3)

NAME
pthread_getspecific -- thread-specific data value LIBRARY
POSIX Threads Library (libpthread, -lpthread) SYNOPSIS
#include <pthread.h> void * pthread_getspecific(pthread_key_t key); int pthread_setspecific(pthread_key_t key, const void *value); DESCRIPTION
The pthread_getspecific() function returns the value currently bound to the specified key on behalf of the calling thread. Conversely, the pthread_setspecific() function associates a thread-specific value with a key obtained via a previous call to pthread_key_create(3). Differ- ent threads have different values bound to each key. These values are typically pointers to blocks of dynamically allocated memory that have been reserved for use by the calling thread. Undefined behavior may follow if either function is called with a key value not obtained from pthread_key_create(3), or if the call is made after key has been deleted with pthread_key_delete(3). It is possible to call either function from a thread-specific data destructor func- tion. Note however that this is not well defined for the pthread_setspecific() function; lost storage or infinite loops may occur. 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, then the value NULL is returned. If successful, the pthread_setspecific() function will return zero. Other- wise an error number will be returned to indicate the error. ERRORS
No errors are defined for either function. SEE ALSO
pthread_key_create(3) STANDARDS
These functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). BSD
July 9, 2010 BSD
Man Page

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

compiling qt

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)
Discussion started by: nydel
2 Replies

2. UNIX for Advanced & Expert Users

PThreads

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)
Discussion started by: S.P.Prasad
3 Replies

3. Programming

pthread_create and scope usage

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)
Discussion started by: jenmead
3 Replies

4. Solaris

Apache config issue

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)
Discussion started by: BrewDudeBob
17 Replies

5. Programming

calling pthread_self (on ubuntu), expensive?

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)
Discussion started by: gorga
11 Replies

6. Programming

GTK C development; question/concern wrt gtk_dialog_run

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)
Discussion started by: DreamWarrior
8 Replies

7. Programming

Check The value a pointer returned by struct s_client != 0

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)
Discussion started by: pooyair
1 Replies

8. AIX

Compiling problem - AIX 7.2

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)
Discussion started by: bobochacha29
10 Replies