From e622406342c6ac1fefec5a3d2800b9c49951ab0d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 29 May 2005 11:44:52 +0200 Subject: [PATCH] Added cThread::SetPriority() and using it in cSectionHandler::Action() to reduce the priority of the section handler threads --- CONTRIBUTORS | 1 + HISTORY | 2 ++ sections.c | 3 ++- thread.c | 8 +++++++- thread.h | 3 ++- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 1c0c2020..eff35c7b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1366,3 +1366,4 @@ Georg Acher for a patch that was used to implement hash tables to speed up cSchedule::GetEvent() for avoiding unnecessary calls to getLength() in libsi/si.c, and avoiding the '& 0xff' in CRC32::crc32() of libsi/util.c + for suggesting to reduce the priority of the section handler threads diff --git a/HISTORY b/HISTORY index 81cbefb6..acbad346 100644 --- a/HISTORY +++ b/HISTORY @@ -3575,3 +3575,5 @@ Video Disk Recorder Revision History - Speeded up deleting duplicate channels. - Fixed listing recordings with empty episode names in the LSTR command (thanks to Stefan Huelswitt for pointing this out). +- Added cThread::SetPriority() and using it in cSectionHandler::Action() to + reduce the priority of the section handler threads (as suggested by Georg Acher). diff --git a/sections.c b/sections.c index 7c42a6ef..6552d56e 100644 --- a/sections.c +++ b/sections.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: sections.c 1.10 2004/10/24 11:05:12 kls Exp $ + * $Id: sections.c 1.11 2005/05/29 11:43:17 kls Exp $ */ #include "sections.h" @@ -167,6 +167,7 @@ void cSectionHandler::SetStatus(bool On) void cSectionHandler::Action(void) { active = true; + SetPriority(19); while (active) { Lock(); diff --git a/thread.c b/thread.c index 013b2179..9ac1b7ef 100644 --- a/thread.c +++ b/thread.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 1.42 2005/05/06 14:39:15 kls Exp $ + * $Id: thread.c 1.43 2005/05/29 11:40:30 kls Exp $ */ #include "thread.h" @@ -208,6 +208,12 @@ cThread::~cThread() free(description); } +void cThread::SetPriority(int Priority) +{ + if (setpriority(PRIO_PROCESS, 0, Priority) < 0) + LOG_ERROR; +} + void cThread::SetDescription(const char *Description, ...) { free(description); diff --git a/thread.h b/thread.h index 2c0ebcba..48d04990 100644 --- a/thread.h +++ b/thread.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.h 1.27 2005/01/14 14:02:14 kls Exp $ + * $Id: thread.h 1.28 2005/05/29 11:31:24 kls Exp $ */ #ifndef __THREAD_H @@ -82,6 +82,7 @@ private: static bool emergencyExitRequested; static void *StartThread(cThread *Thread); protected: + void SetPriority(int Priority); void Lock(void) { mutex.Lock(); } void Unlock(void) { mutex.Unlock(); } virtual void Action(void) = 0;