---
name: "set_tid_address"
section: "2"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/set_tid_address"
---

# set\_tid\_address(2)

set pointer to thread ID

## NAME

set\_tid\_address - set pointer to thread ID

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <sys/syscall.h>      /* Definition of SYS_* constants */
#include <unistd.h>
```

**pid\_t syscall(SYS\_set\_tid\_address, int \****tidptr***);**

*Note*: glibc provides no wrapper for **set\_tid\_address**(), necessitating the use of [**syscall**(2)](/syscall/2.md).

## DESCRIPTION

For each thread, the kernel maintains two attributes (addresses) called *set\_child\_tid* and *clear\_child\_tid*. These two attributes contain the value NULL by default.

- *set\_child\_tid*

  If a thread is started using [**clone**(2)](/clone/2.md) with the **CLONE\_CHILD\_SETTID** flag, *set\_child\_tid* is set to the value passed in the *ctid* argument of that system call.

-

  When *set\_child\_tid* is set, the very first thing the new thread does is to write its thread ID at this address.

- *clear\_child\_tid*

  If a thread is started using [**clone**(2)](/clone/2.md) with the **CLONE\_CHILD\_CLEARTID** flag, *clear\_child\_tid* is set to the value passed in the *ctid* argument of that system call.

The system call **set\_tid\_address**() sets the *clear\_child\_tid* value for the calling thread to *tidptr*.

When a thread whose *clear\_child\_tid* is not NULL terminates, then, if the thread is sharing memory with other threads, then 0 is written at the address specified in *clear\_child\_tid* and the kernel performs the following operation:

```
futex(clear_child_tid, FUTEX_WAKE, 1, NULL, NULL, 0);
```

The effect of this operation is to wake a single thread that is performing a futex wait on the memory location. Errors from the futex wake operation are ignored.

## RETURN VALUE

**set\_tid\_address**() always returns the caller's thread ID.

## ERRORS

**set\_tid\_address**() always succeeds.

## STANDARDS

Linux.

## HISTORY

Linux 2.5.48.

Details as given here are valid since Linux 2.5.49.

## SEE ALSO

[**clone**(2)](/clone/2.md), [**futex**(2)](/futex/2.md), [**gettid**(2)](/gettid/2.md)
