]> git.ipfire.org Git - thirdparty/man-pages.git/blob - man2/set_tid_address.2
mmap.2: Don't mark MAP_ANON as deprecated
[thirdparty/man-pages.git] / 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 2017-09-15 "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 .PP
32 .BI "long set_tid_address(int *" tidptr );
33 .fi
34 .PP
35 .IR Note :
36 There is no glibc wrapper for this system call; see NOTES.
37 .SH DESCRIPTION
38 For each thread, the kernel maintains two attributes (addresses) called
39 .I set_child_tid
40 and
41 .IR clear_child_tid .
42 These two attributes contain the value NULL by default.
43 .TP
44 .I set_child_tid
45 If a thread is started using
46 .BR clone (2)
47 with the
48 .B CLONE_CHILD_SETTID
49 flag,
50 .I set_child_tid
51 is set to the value passed in the
52 .I ctid
53 argument of that system call.
54 .IP
55 When
56 .I set_child_tid
57 is set, the very first thing the new thread does
58 is to write its thread ID at this address.
59 .TP
60 .I clear_child_tid
61 If a thread is started using
62 .BR clone (2)
63 with the
64 .B CLONE_CHILD_CLEARTID
65 flag,
66 .I clear_child_tid
67 is set to the value passed in the
68 .I ctid
69 argument of that system call.
70 .PP
71 The system call
72 .BR set_tid_address ()
73 sets the
74 .I clear_child_tid
75 value for the calling thread to
76 .IR tidptr .
77 .PP
78 When a thread whose
79 .I clear_child_tid
80 is not NULL terminates, then,
81 if the thread is sharing memory with other threads,
82 then 0 is written at the address specified in
83 .I clear_child_tid
84 and the kernel performs the following operation:
85 .PP
86 futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
87 .PP
88 The effect of this operation is to wake a single thread that
89 is performing a futex wait on the memory location.
90 Errors from the futex wake operation are ignored.
91 .SH RETURN VALUE
92 .BR set_tid_address ()
93 always returns the caller's thread ID.
94 .SH ERRORS
95 .BR set_tid_address ()
96 always succeeds.
97 .SH VERSIONS
98 This call is present since Linux 2.5.48.
99 Details as given here are valid since Linux 2.5.49.
100 .SH CONFORMING TO
101 This system call is Linux-specific.
102 .SH NOTES
103 Glibc does not provide a wrapper for this system call; call it using
104 .BR syscall (2).
105 .SH SEE ALSO
106 .BR clone (2),
107 .BR futex (2),
108 .BR gettid (2)