OSDN Git Service

9eda28ef5538c6b50e6b95d7e3d34a87347de835
[linuxjm/LDP_man-pages.git] / original / man2 / set_tid_address.2
1 .\" Copyright (C) 2004 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
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 .\" %%%LICENSE_END
24 .\"
25 .TH SET_TID_ADDRESS 2 2012-07-19 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 set_tid_address \- set pointer to thread ID
28 .SH SYNOPSIS
29 .nf
30 .B #include <linux/unistd.h>
31 .sp
32 .BI "long set_tid_address(int *" tidptr );
33 .fi
34 .SH DESCRIPTION
35 For each process, the kernel maintains two attributes (addresses) called
36 .I set_child_tid
37 and
38 .IR clear_child_tid .
39 These two attributes contain the value NULL by default.
40 .TP
41 .I set_child_tid
42 If a process is started using
43 .BR clone (2)
44 with the
45 .B CLONE_CHILD_SETTID
46 flag,
47 .I set_child_tid
48 is set to the value passed in the
49 .I ctid
50 argument of that system call.
51 .IP
52 When
53 .I set_child_tid
54 is set, the very first thing the new process does
55 is writing its PID at this address.
56 .TP
57 .I clear_child_tid
58 If a process is started using
59 .BR clone (2)
60 with the
61 .B CLONE_CHILD_CLEARTID
62 flag,
63 .I clear_child_tid
64 is set to the value passed in the
65 .I ctid
66 argument of that system call.
67 .LP
68 The system call
69 .BR set_tid_address ()
70 sets the
71 .I clear_child_tid
72 value for the calling process to
73 .IR tidptr .
74 .LP
75 When a process whose
76 .I clear_child_tid
77 is not NULL terminates, then,
78 if the process is sharing memory with other processes or threads,
79 then 0 is written at the address specified in
80 .I clear_child_tid
81 and the kernel performs the following operation:
82
83     futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
84
85 The effect of this operation is to wake a single process that
86 is performing a futex wait on the memory location.
87 Errors from the futex wake operation are ignored.
88 .SH RETURN VALUE
89 .BR set_tid_address ()
90 always returns the PID of the calling process.
91 .SH ERRORS
92 .BR set_tid_address ()
93 always succeeds.
94 .SH VERSIONS
95 This call is present since Linux 2.5.48.
96 Details as given here are valid since Linux 2.5.49.
97 .SH CONFORMING TO
98 This system call is Linux-specific.
99 .SH SEE ALSO
100 .BR clone (2),
101 .BR futex (2)
102 .SH COLOPHON
103 This page is part of release 3.67 of the Linux
104 .I man-pages
105 project.
106 A description of the project,
107 information about reporting bugs,
108 and the latest version of this page,
109 can be found at
110 \%http://www.kernel.org/doc/man\-pages/.