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

DESCRIPTION

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

RETURN VALUE

46       set_tid_address() always returns the PID of the calling process.
47

ERRORS

49       set_tid_address() always succeeds.
50

VERSIONS

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

CONFORMING TO

56       This system call is Linux-specific.
57

SEE ALSO

59       clone(2), futex(2)
60

COLOPHON

62       This  page  is  part of release 3.53 of the Linux man-pages project.  A
63       description of the project, and information about reporting  bugs,  can
64       be found at http://www.kernel.org/doc/man-pages/.
65
66
67
68Linux                             2012-07-19                SET_TID_ADDRESS(2)
Impressum