[vdr] VDR gets somehow stuck and consumes all CPU time

Johannes Stezenbach js at linuxtv.org
Sat Dec 3 20:36:14 CET 2005

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.)


--- 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 <unistd.h>
 #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());
   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;

More information about the vdr mailing list