diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2012-10-04 12:32:31 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2012-10-04 12:32:31 +0200 |
commit | 1e9b16d20bacb9795a07af5ff61db67fc78c3728 (patch) | |
tree | 89f487b4781a65b81e2625f28a18207e82eb1cec /thread.c | |
parent | 5a407d0e68c8b0ef00613f6839aeadbf6b92224a (diff) | |
download | vdr-1e9b16d20bacb9795a07af5ff61db67fc78c3728.tar.gz vdr-1e9b16d20bacb9795a07af5ff61db67fc78c3728.tar.bz2 |
The cThread constructor now has an additional boolean parameter that can be set to true to have this thread run at a lower priority
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 2.5 2012/09/20 09:05:50 kls Exp $ + * $Id: thread.c 2.6 2012/10/04 12:20:43 kls Exp $ */ #include "thread.h" @@ -204,7 +204,7 @@ void cMutex::Unlock(void) tThreadId cThread::mainThreadId = 0; -cThread::cThread(const char *Description) +cThread::cThread(const char *Description, bool LowPriority) { active = running = false; childTid = 0; @@ -212,6 +212,7 @@ cThread::cThread(const char *Description) description = NULL; if (Description) SetDescription("%s", Description); + lowPriority = LowPriority; } cThread::~cThread() @@ -248,12 +249,16 @@ void *cThread::StartThread(cThread *Thread) { Thread->childThreadId = ThreadId(); if (Thread->description) { - dsyslog("%s thread started (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId); + dsyslog("%s thread started (pid=%d, tid=%d, prio=%s)", Thread->description, getpid(), Thread->childThreadId, Thread->lowPriority ? "low" : "high"); #ifdef PR_SET_NAME if (prctl(PR_SET_NAME, Thread->description, 0, 0, 0) < 0) esyslog("%s thread naming failed (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId); #endif } + if (Thread->lowPriority) { + Thread->SetPriority(19); + Thread->SetIOPriority(7); + } Thread->Action(); if (Thread->description) dsyslog("%s thread ended (pid=%d, tid=%d)", Thread->description, getpid(), Thread->childThreadId); |