On Sun, Dec 04, 2005 at 10:37:42AM +0100, Klaus Schmidinger wrote:
Johannes Stezenbach wrote:
On Sat, Dec 03, 2005, Klaus Schmidinger wrote:
(AFAIK with NPTL all threads of a given program have the same pid, so you won't be able to distinguish them in 'top').
This is not entirely true, you can still see and distinguish the threads in htop or "ps -T u -C vdr" etc. (top does not work).
The patch below might help, gettid() returns the PID of the thread. (And since it's a syscall it is independent of NPTL vs. linuxthreads. Tested on 2.6 only, but the gettid man page says it's available in 2.4.20. gettid() is Linux specific.)
Does this "gettid" call return a different tid than "pthread_self()"?
I'm just wondering because the introduction of "pthread_self()" was one of the things we had to change to make VDR run with NPTL...
pthread_self() has to be used within programs using to identify the threads. gettid() is more a debugging aid as the return value of pthread_self() has no meaning outside the context of the running program. (Funny that glibc doesn't have a syscall wrapper for gettid(); dietlibc has.)
Johannes