<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
.style2 {font-size: 14px}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
-->
</style></head>
<body style="margin:0px 0px 0px 0px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">sys_set_tid_address <span class="style2">[kernel/fork.c] </span></span></td>
</tr>
<tr>
<td><p style="margin-left:22px;margin-top:0px"><br />
Sets pointer to thread ID.<br />
<br />
The kernel keeps for each process two values called <em>set_child_tid</em> and <em>clear_child_tid</em> that are NULL by default:<br />
<br />
<u><em>set_child_tid<br />
<br />
</em></u>If a process is started using <a href="120.html">sys_clone</a> with the CLONE_CHILD_SETTID flag, <em>set_child_tid</em> is set to<em> </em>the fifth parameter of that system call.<br />
When <em>set_child_tid</em> is set, the very first thing the new process does is writing its PID at this address.<br />
<br />
<u><em>clear_child_tid<br />
<br />
</em></u>If a process is started using<a href="120.html"> sys_clone</a> with the CLONE_CHILD_CLEARTID flag, <em>clear_child_tid</em> is set to<em> </em>the fifth parameter of that system call.<br />
<br />
The system call set_tid_address sets the <em>clear_child_tid</em> value for the calling process to a value pointed by <em>ebx.<br />
<br />
</em>When <em>clear_child_tid</em> is set, and the process exits, and the process was sharing memory with other processes or threads, then 0 is written at this address, and a sys_futex with<em> ebx</em>=<em>child_tidptr, edx</em>=FUTEX_WAKE<em>, edx</em>=1<em>;</em> call is done. (That is, wake a single process waiting on this futex.) Errors are ignored. </p>
<p style="margin-left:10px"><strong>Arguments</strong></p>
<table width="100%" border="0" style="margin-left:20px; margin-right:20px">
<tr>
<td width="6%" valign="top"><em>eax</em></td>
<td width="94%">258</td>
</tr>
<tr>
<td valign="top"><em>ebx</em></td>
<td>Pointer to a value specifying the thread ID. </td>
</tr>
</table>
<p style="margin-left:10px" ><strong>Return values</strong></p>
<p style="margin-left:22px;margin-right:10px" >This system call always succeeds and returns PID of the current process. </p>
<p style="margin-left:10px"><strong>Remarks</strong></p>
<p style="margin-left:22px">n/a</p>
<p style="margin-left:10px"><strong>Compatibility</strong></p>
<p style="margin-left:22px">n/a</p></td>
</tr>
</table></body></html>