When is the set_tid_address system call used?

I am trying to make system calls and want to understand how set_tid_address works. basically from what i read is that it returns the pid of the program or process that is running.

I tested this with ls, however with some commands like uptime, top, etc., I don't see the set_tid_address that is used. Why is this?

+2
python system-calls
source share
2 answers

The clone() script can accept the CLONE_CHILD_CLEARTID flag, which is cleared of the value of child_tidptr (another clone() argument), and the associated futex signal wakes up when the child stream exits. This is used to implement pthread_join() (the parent thread is expecting futex).

set_tid_address() allows pthread_join() in the source thread. Additional information in the following LKML threads:

fix fix fix, tid-2.5.47-A3
[patch] user-vm-unlock-2.5.31-A2

As for why some programs call set_tid_address() and others not, the answer is simple. Programs related (directly or indirectly) to the libpthread set_tid_address . ls is associated with librt , which is associated with libpthread , so it starts initialization for NPTL.

+3
source share

According to the Linux Programmer Manual , set_tid_address is used for:

set pointer to stream id

When it is completed, it will return the PID of the calling process. Unfortunately, the manual is unclear when you really want to use this system call.

In any case, why do you think these commands use set_tid_address ?

0
source share

All Articles