1SET_TID_ADDRESS(2)         Linux Programmer's Manual        SET_TID_ADDRESS(2)
2
3
4

NAME

6       set_tid_address - set pointer to thread ID
7

SYNOPSIS

9       #include <linux/unistd.h>
10
11       long set_tid_address(int *tidptr);
12
13       Note: There is no glibc wrapper for this system call; see NOTES.
14

DESCRIPTION

16       For each thread, the kernel maintains two attributes (addresses) called
17       set_child_tid and clear_child_tid.  These two  attributes  contain  the
18       value NULL by default.
19
20       set_child_tid
21              If  a thread is started using clone(2) with the CLONE_CHILD_SET‐
22              TID flag, set_child_tid is set to the value passed in  the  ctid
23              argument of that system call.
24
25              When  set_child_tid  is set, the very first thing the new thread
26              does is to write its thread ID at this address.
27
28       clear_child_tid
29              If   a   thread   is   started   using   clone(2)    with    the
30              CLONE_CHILD_CLEARTID  flag,  clear_child_tid is set to the value
31              passed in the ctid argument of that system call.
32
33       The system call set_tid_address() sets the  clear_child_tid  value  for
34       the calling thread to tidptr.
35
36       When  a  thread  whose clear_child_tid is not NULL terminates, then, if
37       the thread is sharing memory with other threads, then 0 is  written  at
38       the  address  specified  in clear_child_tid and the kernel performs the
39       following operation:
40
41           futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
42
43       The effect of this operation is to wake a single thread  that  is  per‐
44       forming  a  futex  wait  on the memory location.  Errors from the futex
45       wake operation are ignored.
46

RETURN VALUE

48       set_tid_address() always returns the caller's thread ID.
49

ERRORS

51       set_tid_address() always succeeds.
52

VERSIONS

54       This call is present since Linux 2.5.48.  Details  as  given  here  are
55       valid since Linux 2.5.49.
56

CONFORMING TO

58       This system call is Linux-specific.
59

NOTES

61       Glibc  does  not  provide a wrapper for this system call; call it using
62       syscall(2).
63

SEE ALSO

65       clone(2), futex(2), gettid(2)
66

COLOPHON

68       This page is part of release 5.07 of the Linux  man-pages  project.   A
69       description  of  the project, information about reporting bugs, and the
70       latest    version    of    this    page,    can     be     found     at
71       https://www.kernel.org/doc/man-pages/.
72
73
74
75Linux                             2017-09-15                SET_TID_ADDRESS(2)
Impressum