
EnzoFerber
(usa FreeBSD)
Enviado em 19/04/2015 - 20:29h
A resposta que você procura está aqui:
http://man7.org/linux/man-pages/man2/gettid.2.html
http://linux.die.net/man/2/gettid
Precisamente, aqui:
gettid() returns the caller's thread ID (TID). In a single-threaded process, the thread ID is equal to the process ID (PID, as returned by getpid(2)). In a multithreaded process, all threads have the same PID, but each one has a unique TID. For further details, see the discussion of CLONE_THREAD in clone(2).
... e aqui:
Notes
Glibc does not provide a wrapper for this system call; call it using syscall(2).
The thread ID returned by this call is not the same thing as a POSIX thread ID (i.e., the opaque value returned by pthread_self(3)).
Explica a diferença entre pthread_self(3), gettid(2) e getpid(2). Também te fala que gettid não é padronizada e não deveria ser utilizada em aplicações portáveis. Primeiro resultado do google por gettid...
Também poderia usar os velhos:
$ man pthread_self
$ man gettid
$ man getpid
Enzo Ferber
[]'s