1PTHREAD_SELF(3) Linux Programmer's Manual PTHREAD_SELF(3)
2
3
4
6 pthread_self - obtain ID of the calling thread
7
9 #include <pthread.h>
10
11 pthread_t pthread_self(void);
12
13 Compile and link with -pthread.
14
16 The pthread_self() function returns the ID of the calling thread. This
17 is the same value that is returned in *thread in the pthread_create(3)
18 call that created this thread.
19
21 This function always succeeds, returning the calling thread's ID.
22
24 This function always succeeds.
25
27 POSIX.1-2001.
28
30 POSIX.1 allows an implementation wide freedom in choosing the type used
31 to represent a thread ID; for example, representation using either an
32 arithmetic type or a structure is permitted. Therefore, variables of
33 type pthread_t can't portably be compared using the C equality operator
34 (==); use pthread_equal(3) instead.
35
36 Thread identifiers should be considered opaque: any attempt to use a
37 thread ID other than in pthreads calls is non-portable and can lead to
38 unspecified results.
39
40 Thread IDs are only guaranteed to be unique within a process. A thread
41 ID may be reused after a terminated thread has been joined, or a
42 detached thread has terminated.
43
44 The thread ID returned by pthread_self() is not the same thing as the
45 kernel thread ID returned by a call to gettid(2).
46
48 pthread_create(3), pthread_equal(3), pthreads(7)
49
51 This page is part of release 3.22 of the Linux man-pages project. A
52 description of the project, and information about reporting bugs, can
53 be found at http://www.kernel.org/doc/man-pages/.
54
55
56
57Linux 2008-10-24 PTHREAD_SELF(3)