1 .\" Copyright (C) 2004 Andries Brouwer (aeb@cwi.nl)
3 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .TH SET_TID_ADDRESS 2 2021-06-20 "Linux" "Linux Programmer's Manual"
7 set_tid_address \- set pointer to thread ID
13 .BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
14 .B #include <unistd.h>
16 .BI "pid_t syscall(SYS_set_tid_address, int *" tidptr );
20 glibc provides no wrapper for
21 .BR set_tid_address (),
22 necessitating the use of
25 For each thread, the kernel maintains two attributes (addresses) called
29 These two attributes contain the value NULL by default.
32 If a thread is started using
38 is set to the value passed in the
40 argument of that system call.
44 is set, the very first thing the new thread does
45 is to write its thread ID at this address.
48 If a thread is started using
51 .B CLONE_CHILD_CLEARTID
54 is set to the value passed in the
56 argument of that system call.
59 .BR set_tid_address ()
62 value for the calling thread to
67 is not NULL terminates, then,
68 if the thread is sharing memory with other threads,
69 then 0 is written at the address specified in
71 and the kernel performs the following operation:
73 futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
75 The effect of this operation is to wake a single thread that
76 is performing a futex wait on the memory location.
77 Errors from the futex wake operation are ignored.
79 .BR set_tid_address ()
80 always returns the caller's thread ID.
82 .BR set_tid_address ()
85 This call is present since Linux 2.5.48.
86 Details as given here are valid since Linux 2.5.49.
88 This system call is Linux-specific.