From patchwork Sat Dec 3 19:36:14 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Stezenbach X-Patchwork-Id: 12108 Received: from allen.werkleitz.de ([80.190.251.108]) by www.linuxtv.org with esmtp (Exim 4.50) id 1EidBT-0004rD-Qa for vdr@linuxtv.org; Sat, 03 Dec 2005 20:36:35 +0100 Received: from p54bdd7ca.dip.t-dialin.net ([84.189.215.202] helo=abc.local) by allen.werkleitz.de with esmtpsa (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1EidAu-0003ZN-1E for vdr@linuxtv.org; Sat, 03 Dec 2005 20:36:05 +0100 Received: from js by abc.local with local (Exim 3.35 #1 (Debian)) id 1EidB8-0001xM-00 for ; Sat, 03 Dec 2005 20:36:14 +0100 Date: Sat, 3 Dec 2005 20:36:14 +0100 From: Johannes Stezenbach To: vdr@linuxtv.org Message-ID: <20051203193614.GA6623@linuxtv.org> Mail-Followup-To: Johannes Stezenbach , vdr@linuxtv.org References: <877japftpm.fsf@sarabi.vip.fi> <43918DE3.6050605@cadsoft.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <43918DE3.6050605@cadsoft.de> User-Agent: Mutt/1.5.11 X-SA-Exim-Connect-IP: 84.189.215.202 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on allen.werkleitz.de X-Spam-Level: X-Spam-Status: No, score=-3.3 required=4.0 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.0 Subject: Re: [vdr] VDR gets somehow stuck and consumes all CPU time X-SA-Exim-Version: 4.2 (built Thu, 03 Mar 2005 10:44:12 +0100) X-SA-Exim-Scanned: Yes (on allen.werkleitz.de) X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2005 19:36:35 -0000 Status: O X-Status: X-Keywords: X-UID: 6479 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.) Johannes --- vdr-1.3.37/thread.c.orig 2005-12-03 19:52:38.000000000 +0100 +++ vdr-1.3.37/thread.c 2005-12-03 20:12:47.000000000 +0100 @@ -17,6 +17,11 @@ #include #include "tools.h" +static inline pid_t gettid(void) +{ + return (pid_t) syscall(224); +} + static bool GetAbsTime(struct timespec *Abstime, int MillisecondsFromNow) { struct timeval now; @@ -231,10 +236,10 @@ void cThread::SetDescription(const char void *cThread::StartThread(cThread *Thread) { if (Thread->description) - dsyslog("%s thread started (pid=%d, tid=%ld)", Thread->description, getpid(), pthread_self()); + dsyslog("%s thread started (pid=%d, tid=%d)", Thread->description, getpid(), gettid()); Thread->Action(); if (Thread->description) - dsyslog("%s thread ended (pid=%d, tid=%ld)", Thread->description, getpid(), pthread_self()); + dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), gettid()); Thread->running = false; Thread->active = false; return NULL;