OSDN Git Service

ce026e3ad1f8949a3953c89bf6ceea22700a750a
[linuxjm/LDP_man-pages.git] / original / man3 / pthread_self.3
1 .\" Copyright (c) 2008 Linux Foundation, written by Michael Kerrisk
2 .\"     <mtk.manpages@gmail.com>
3 .\"
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\"
24 .TH PTHREAD_SELF 3 2008-10-24 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 pthread_self \- obtain ID of the calling thread
27 .SH SYNOPSIS
28 .nf
29 .B #include <pthread.h>
30
31 .B pthread_t pthread_self(void);
32 .sp
33 Compile and link with \fI\-pthread\fP.
34 .SH DESCRIPTION
35 The
36 .BR pthread_self ()
37 function returns the ID of the calling thread.
38 This is the same value that is returned in
39 .IR *thread
40 in the
41 .BR pthread_create (3)
42 call that created this thread.
43 .SH RETURN VALUE
44 This function always succeeds, returning the calling thread's ID.
45 .SH ERRORS
46 This function always succeeds.
47 .SH CONFORMING TO
48 POSIX.1-2001.
49 .SH NOTES
50 POSIX.1 allows an implementation wide freedom in choosing
51 the type used to represent a thread ID;
52 for example, representation using either an arithmetic type or
53 a structure is permitted.
54 Therefore, variables of type
55 .I pthread_t
56 can't portably be compared using the C equality operator (\fB==\fP);
57 use
58 .BR pthread_equal (3)
59 instead.
60
61 Thread identifiers should be considered opaque:
62 any attempt to use a thread ID other than in pthreads calls
63 is nonportable and can lead to unspecified results.
64
65 Thread IDs are only guaranteed to be unique within a process.
66 A thread ID may be reused after a terminated thread has been joined,
67 or a detached thread has terminated.
68
69 The thread ID returned by
70 .BR pthread_self ()
71 is not the same thing as the kernel thread ID returned by a call to
72 .BR gettid (2).
73 .SH SEE ALSO
74 .BR pthread_create (3),
75 .BR pthread_equal (3),
76 .BR pthreads (7)