1 .\" Copyright (C) 2004 Andries Brouwer (aeb@cwi.nl)
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.
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.
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
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .TH SET_TID_ADDRESS 2 2020-12-21 "Linux" "Linux Programmer's Manual"
27 set_tid_address \- set pointer to thread ID
30 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
31 .B #include <unistd.h>
33 .BI "pid_t syscall(SYS_set_tid_address, int *" tidptr );
37 glibc provides no wrapper for
38 .BR set_tid_address (),
39 necessitating the use of
42 For each thread, the kernel maintains two attributes (addresses) called
46 These two attributes contain the value NULL by default.
49 If a thread is started using
55 is set to the value passed in the
57 argument of that system call.
61 is set, the very first thing the new thread does
62 is to write its thread ID at this address.
65 If a thread is started using
68 .B CLONE_CHILD_CLEARTID
71 is set to the value passed in the
73 argument of that system call.
76 .BR set_tid_address ()
79 value for the calling thread to
84 is not NULL terminates, then,
85 if the thread is sharing memory with other threads,
86 then 0 is written at the address specified in
88 and the kernel performs the following operation:
90 futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
92 The effect of this operation is to wake a single thread that
93 is performing a futex wait on the memory location.
94 Errors from the futex wake operation are ignored.
96 .BR set_tid_address ()
97 always returns the caller's thread ID.
99 .BR set_tid_address ()
102 This call is present since Linux 2.5.48.
103 Details as given here are valid since Linux 2.5.49.
105 This system call is Linux-specific.