Gerald Raaf wrote: > Am Sonntag, 4. Dezember 2005 10:37 schrieb Klaus Schmidinger: > >>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()"? >> > > > pthread_self() sample output log > [2005/12/04 11:14:02] vdr vdr[27644]: tuner on device 3 thread started > (pid=27644, tid=-1265644624) > sample output ps -T u -C vdr > root@vdr:~# ps -T u -C vdr > USER PID SPID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > root 27644 27644 3.2 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27742 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27743 0.0 2.5 129332 26624 ? RNl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27745 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27746 0.0 2.5 129332 26624 ? SNl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27748 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27749 0.0 2.5 129332 26624 ? SNl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27750 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27751 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27752 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 27644 27753 0.0 2.5 129332 26624 ? Sl 11:14 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > > > gettid() sample output log with Patch from Johannes Stetzenbach > [2005/12/04 11:16:15] vdr vdr[29989]: tuner on device 3 thread started > (pid=29989, tid=30086) > sample output ps -T u -C vdr > root@vdr:~# ps -T u -C vdr > USER PID SPID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND > root 29989 29989 0.1 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30080 0.0 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30081 0.0 2.5 129380 26640 ? SNl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30083 0.0 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30084 0.0 2.5 129380 26640 ? SNl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30086 0.0 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30087 0.0 2.5 129380 26640 ? SNl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30088 0.0 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30089 0.0 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30090 0.0 2.5 129380 26640 ? Sl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > root 29989 30091 0.0 2.5 129380 26640 ? Rl 11:16 0:00 ./vdr -w 60 -s /usr/local/bin/stopvdr -r /usr/local/bin/record.sh - > > my System is a NPTL only System (Linuxfromscatch System) with vdr-1.3.37. Well, this shows me that on such a system all VDR threads have the same PID, but different SPIDs. I don't think that this has in any way changed through Johannes' patch. What would be interesting would be the log excerpts corresponding to these test runs, where the VDR threads log their 'pid' and 'tid' values. Maybe you could post these, too? Klaus