1 .\" Copyright (C) 2004 Andries Brouwer (aeb@cwi.nl)
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" Japanese Version Copyright (c) 2005 Yuichi SATO
24 .\" all rights reserved.
25 .\" Translated Wed Jan 26 07:21:01 JST 2005
26 .\" by Yuichi SATO <ysato444@yahoo.co.jp>
28 .TH SET_TID_ADDRESS 2 2004-09-10 "Linux" "Linux Programmer's Manual"
31 .\"O set_tid_address \- set pointer to thread ID
32 set_tid_address \- ¥¹¥ì¥Ã¥É ID ¤Ø¤Î¥Ý¥¤¥ó¥¿¤òÀßÄꤹ¤ë
36 .B #include <linux/unistd.h>
38 .BI "long set_tid_address(int *" tidptr );
42 .\"O The kernel keeps for each process two values called
45 .\"O .I clear_child_tid
46 .\"O that are NULL by default.
47 ¥«¡¼¥Í¥ë¤Ï³Æ¥×¥í¥»¥¹¤Ë¤Ä¤¤¤Æ
51 ¤È¤¤¤¦ 2 ¤Ä¤ÎÃͤòÊÝ»ý¤¹¤ë¡£
52 ¤³¤ì¤é¤Ï¥Ç¥Õ¥©¥ë¥È¤Ç¤Ï NULL ¤Ç¤¢¤ë¡£
54 .\"O If a process is started using
57 .\"O .B CLONE_CHILD_SETTID
61 .\"O .IR child_tidptr ,
62 .\"O the fifth argument of that system call.
67 ¤Ë¤è¤Ã¤Æ³«»Ï¤µ¤ì¤¿¾ì¹ç¡¢
74 ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î 5 ÈÖÌܤΰú¤¿ô¤Ç¤¢¤ë¡£
76 .\"Osato: __syscall5 ¤Ç __NR_clone ¤ò¸Æ¤Ó½Ð¤¹¤È¤¤Î
77 .\"Osato: 5 ÈÖÌܤΰú¤¿ô¤È¤¤¤¦¤³¤È¤À¤í¤¦¤«¡£
82 .\"O is set, the very first thing the new process does
83 .\"O is writing its PID at this address.
85 ¤¬ÀßÄꤵ¤ì¤¿¾ì¹ç¡¢°ìÈֺǽé¤Ë¿·¤·¤¤¥×¥í¥»¥¹¤¬¹Ô¤¦¤³¤È¤Ï¡¢
86 ¤³¤Î¥¢¥É¥ì¥¹¤Ë¼«¿È¤Î PID ¤ò½ñ¤¹þ¤à¤³¤È¤Ç¤¢¤ë¡£
88 .\"O If a process is started using
91 .\"O .B CLONE_CHILD_CLEARTID
93 .\"O .I clear_child_tid
95 .\"O .IR child_tidptr ,
96 .\"O the fifth argument of that system call.
98 .B CLONE_CHILD_CLEARTID
101 ¤Ë¤è¤Ã¤Æ³«»Ï¤µ¤ì¤¿¾ì¹ç¡¢
108 ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î 5 ÈÖÌܤΰú¤¿ô¤Ç¤¢¤ë¡£
111 .\"O .BR set_tid_address ()
113 .\"O .I clear_child_tid
114 .\"O value for the calling process to
117 .BR set_tid_address ()
118 ¤Ï¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î
125 .\"O .I clear_child_tid
126 .\"O is set, and the process exits, and the process was sharing memory
127 .\"O with other processes or threads, then 0 is written at this address,
129 .\"O .I futex(child_tidptr, FUTEX_WAKE, 1, NULL, NULL, 0);
131 .\"O (That is, wake a single process waiting on this futex.)
132 .\"O Errors are ignored.
134 ¤¬ÀßÄꤵ¤ì¤Æ¤¤¤ë¤È¤¤Ë¥×¥í¥»¥¹¤¬½ªÎ»¤¹¤ë¤È¡¢
135 ¤½¤Î¥×¥í¥»¥¹¤Ï¾¤Î¥×¥í¥»¥¹¤Þ¤¿¤Ï¥¹¥ì¥Ã¥É¤È¥á¥â¥ê¤ò¶¦Í¤·¤Æ¤¤¤ë¤Î¤Ç¡¢
136 ¤³¤Î¥¢¥É¥ì¥¹¤Ë 0 ¤¬½ñ¤¹þ¤Þ¤ì¡¢
137 .I futex(child_tidptr, FUTEX_WAKE, 1, NULL, NULL, 0);
138 ¤Î¸Æ¤Ó½Ð¤·¤¬¼Â¹Ô¤µ¤ì¤ë
139 (¤Ä¤Þ¤ê¡¢¤³¤Î futex ¤ÇÂԤäƤ¤¤ë 1 ¤Ä¤Î¥×¥í¥»¥¹¤òµ¯¤³¤¹ (wake))¡£
141 .\"O .SH "RETURN VALUE"
143 .\"O .BR set_tid_address ()
144 .\"O always returns the PID of the calling process.
145 .BR set_tid_address ()
146 ¤Ï¾ï¤Ë¸½ºß¤Î¥×¥í¥»¥¹¤Î PID ¤òÊÖ¤¹¡£
149 .\"O .BR set_tid_address ()
150 .\"O always succeeds.
151 .BR set_tid_address ()
155 .\"O This call is present since Linux 2.5.48.
156 .\"O Details as given here are valid since Linux 2.5.49.
157 ¤³¤Î¸Æ¤Ó½Ð¤·¤Ï Linux 2.5.48 °Ê¹ß¤Ç¸ºß¤¹¤ë¡£
158 ¤³¤³¤Ç½ñ¤«¤ì¤¿¾ÜºÙ¤Ï Linux 2.5.49 °Ê¹ß¤Ç͸ú¤Ç¤¢¤ë¡£
159 .\"O .SH "CONFORMING TO"
161 .\"O This system call is Linux-specific.
162 ¤³¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux Æȼ«¤Ç¤¢¤ë¡£