]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/set_tid_address.2
Many pages: Use correct letter case in page titles (TH)
[thirdparty/man-pages.git] / man2 / set_tid_address.2
CommitLineData
fea681da
MK
1.\" Copyright (C) 2004 Andries Brouwer (aeb@cwi.nl)
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
fea681da 4.\"
4c1c5274 5.TH set_tid_address 2 (date) "Linux man-pages (unreleased)"
fea681da
MK
6.SH NAME
7set_tid_address \- set pointer to thread ID
18af3cc8
AC
8.SH LIBRARY
9Standard C library
8fc3b2cf 10.RI ( libc ", " \-lc )
fea681da
MK
11.SH SYNOPSIS
12.nf
18e21e1e
AC
13.BR "#include <sys/syscall.h>" " /* Definition of " SYS_* " constants */"
14.B #include <unistd.h>
68e4db0a 15.PP
18e21e1e 16.BI "pid_t syscall(SYS_set_tid_address, int *" tidptr );
c8250206 17.fi
dbfe9c70 18.PP
0f86e5b1 19.IR Note :
18e21e1e
AC
20glibc provides no wrapper for
21.BR set_tid_address (),
22necessitating the use of
23.BR syscall (2).
fea681da 24.SH DESCRIPTION
b5693a38 25For each thread, the kernel maintains two attributes (addresses) called
fea681da
MK
26.I set_child_tid
27and
72442c68
MK
28.IR clear_child_tid .
29These two attributes contain the value NULL by default.
568c4c02
MK
30.TP
31.I set_child_tid
b5693a38 32If a thread is started using
fea681da
MK
33.BR clone (2)
34with the
35.B CLONE_CHILD_SETTID
36flag,
37.I set_child_tid
f5fe5952
MK
38is set to the value passed in the
39.I ctid
40argument of that system call.
568c4c02 41.IP
fea681da
MK
42When
43.I set_child_tid
b5693a38
MK
44is set, the very first thing the new thread does
45is to write its thread ID at this address.
568c4c02
MK
46.TP
47.I clear_child_tid
b5693a38 48If a thread is started using
fea681da
MK
49.BR clone (2)
50with the
51.B CLONE_CHILD_CLEARTID
c13182ef 52flag,
fea681da 53.I clear_child_tid
f5fe5952
MK
54is set to the value passed in the
55.I ctid
56argument of that system call.
dd3568a1 57.PP
fea681da 58The system call
e511ffb6 59.BR set_tid_address ()
fea681da
MK
60sets the
61.I clear_child_tid
b5693a38 62value for the calling thread to
fea681da 63.IR tidptr .
dd3568a1 64.PP
b5693a38 65When a thread whose
4e9ee225
MK
66.I clear_child_tid
67is not NULL terminates, then,
b5693a38 68if the thread is sharing memory with other threads,
4e9ee225 69then 0 is written at the address specified in
fea681da 70.I clear_child_tid
4e9ee225 71and the kernel performs the following operation:
efeece04 72.PP
1ae6b2c7
AC
73.in +4n
74.EX
75futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
76.EE
77.in
efeece04 78.PP
b5693a38 79The effect of this operation is to wake a single thread that
4e9ee225
MK
80is performing a futex wait on the memory location.
81Errors from the futex wake operation are ignored.
47297adb 82.SH RETURN VALUE
e511ffb6 83.BR set_tid_address ()
b5693a38 84always returns the caller's thread ID.
bd0a01ce
MK
85.SH ERRORS
86.BR set_tid_address ()
87always succeeds.
889829be 88.SH VERSIONS
fea681da
MK
89This call is present since Linux 2.5.48.
90Details as given here are valid since Linux 2.5.49.
3113c7f3 91.SH STANDARDS
8382f16d 92This system call is Linux-specific.
47297adb 93.SH SEE ALSO
fea681da 94.BR clone (2),
6351139b
MK
95.BR futex (2),
96.BR gettid (2)