gettid
gettid is a Linux-specific system call that returns the thread ID (TID) of the calling thread. The TID is a kernel-assigned identifier that uniquely identifies a thread within the system, and it is distinct from the process ID (PID) and the thread group ID (TGID) used by the process as a whole.
In Linux, a process can consist of multiple threads that share the same TGID (and thus the
Calling gettid in C is done through a system call, commonly via syscall(SYS_gettid). For example, you can
pid_t tid = syscall(SYS_gettid);
Some C libraries may provide a wrapper around this system call, but gettid is not part of
Portability and usage considerations: Because gettid is Linux-specific, code that relies on it is not portable