Made cCondWait::SleepMs() sleep at least 3ms to avoid a possible busy wait

This commit is contained in:
Klaus Schmidinger 2005-01-14 14:08:47 +01:00
parent 0d596d0478
commit 0ad4b2a713
5 changed files with 10 additions and 7 deletions

View File

@ -3298,3 +3298,4 @@ Video Disk Recorder Revision History
for "Setup/DVB/Audio language(s)" (thanks to Rolf Ahrenberg). for "Setup/DVB/Audio language(s)" (thanks to Rolf Ahrenberg).
- Completed the Estonian OSD texts and switched to iso8859-13 character set - Completed the Estonian OSD texts and switched to iso8859-13 character set
(thanks to Arthur Konovalov). (thanks to Arthur Konovalov).
- Made cCondWait::SleepMs() sleep at least 3ms to avoid a possible busy wait.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbdevice.c 1.113 2005/01/09 13:04:20 kls Exp $ * $Id: dvbdevice.c 1.114 2005/01/14 14:00:44 kls Exp $
*/ */
#include "dvbdevice.h" #include "dvbdevice.h"
@ -1111,7 +1111,7 @@ void cDvbDevice::StillPicture(const uchar *Data, int Length)
#define MIN_IFRAME 400000 #define MIN_IFRAME 400000
for (int i = MIN_IFRAME / Length + 1; i > 0; i--) { for (int i = MIN_IFRAME / Length + 1; i > 0; i--) {
safe_write(fd_video, Data, Length); safe_write(fd_video, Data, Length);
cCondWait::SleepMs(1); // allows the buffer to be displayed in case the progress display is active cCondWait::SleepMs(3); // allows the buffer to be displayed in case the progress display is active
} }
#endif #endif
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbplayer.c 1.29 2004/12/26 11:45:34 kls Exp $ * $Id: dvbplayer.c 1.30 2005/01/14 14:00:56 kls Exp $
*/ */
#include "dvbplayer.h" #include "dvbplayer.h"
@ -439,7 +439,7 @@ void cDvbPlayer::Action(void)
} }
} }
else else
cCondWait::SleepMs(1); // this keeps the CPU load low cCondWait::SleepMs(3); // this keeps the CPU load low
} }
// Store the frame in the buffer: // Store the frame in the buffer:

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: thread.c 1.40 2004/12/19 10:43:14 kls Exp $ * $Id: thread.c 1.41 2005/01/14 13:59:48 kls Exp $
*/ */
#include "thread.h" #include "thread.h"
@ -36,7 +36,7 @@ cCondWait::~cCondWait()
void cCondWait::SleepMs(int TimeoutMs) void cCondWait::SleepMs(int TimeoutMs)
{ {
cCondWait w; cCondWait w;
w.Wait(TimeoutMs); w.Wait(max(TimeoutMs, 3)); // making sure the time is >2ms to avoid a possible busy wait
} }
bool cCondWait::Wait(int TimeoutMs) bool cCondWait::Wait(int TimeoutMs)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: thread.h 1.26 2004/12/19 10:43:10 kls Exp $ * $Id: thread.h 1.27 2005/01/14 14:02:14 kls Exp $
*/ */
#ifndef __THREAD_H #ifndef __THREAD_H
@ -26,6 +26,8 @@ public:
///< Creates a cCondWait object and uses it to sleep for TimeoutMs ///< Creates a cCondWait object and uses it to sleep for TimeoutMs
///< milliseconds, immediately giving up the calling thread's time ///< milliseconds, immediately giving up the calling thread's time
///< slice and thus avoiding a "busy wait". ///< slice and thus avoiding a "busy wait".
///< In order to avoid a possible busy wait, TimeoutMs will be automatically
///< limited to values >2.
bool Wait(int TimeoutMs = 0); bool Wait(int TimeoutMs = 0);
///< Waits at most TimeoutMs milliseconds for a call to Signal(), or ///< Waits at most TimeoutMs milliseconds for a call to Signal(), or
///< forever if TimeoutMs is 0. ///< forever if TimeoutMs is 0.