set_tid_address (nr 218)
Linux Signature
pid_t set_tid_address(int *tidptr);
Description
Sets the clear_child_tid pointer for the calling thread. When the thread exits, the kernel writes 0 to *tidptr and wakes any futex waiters. Returns the caller’s TID.
Current Implementation
- Ignores the
tidptrargument entirely (noclear_child_tidtracking). - Returns the current process’s PID (used as TID since each process is single-threaded).
This is sufficient for musl’s early startup, which calls set_tid_address to discover its own TID.
Source: osl/src/syscalls/process.rs — sys_set_tid_address
Future Work
- Store
tidptrin the thread/process structure. - On thread exit, write 0 to
*tidptrand perform a futex wake (needed forpthread_join). - Return a per-thread TID rather than PID once multi-threading is supported.