Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: VDR developer version 1.3.18 with NTPL



Mattias Grönlund wrote:
Hi,

I must have missed something, but the implementation of:
cCondWait::SleepMs(int TimeoutMs)
{
  cCondWait w;
  w.Wait(TimeoutMS);
}

Will if I understand this right, create a new cCondWait instance and than
wait for TimeoutMs milliseconds before returning, but no other threads know
about this new cCondWait object and can therefore not signal it to break
before the timeout has elapsed.

If I understood the NTPL problem right, pthread_cond_timedwait will spin
lock for up to two milliseconds (one this specific case), so it will not
work as expected.
So does this mean that for values of TimeoutMS larger than two milliseconds
it would work as expected? In that case maybe simply changing to

    cCondWait::SleepMs(3); // this keeps the CPU load low

might help. The actual wait time isn't that critical here - there's nothing to
do, anyway. We could even do

cCondWait::SleepMs(int TimeoutMs)
{
  cCondWait w;
  w.Wait(max(TimeoutMS, 3));
}

to make sure no values less than 3 are used (and define this as SleepMs()'s
behaviour).

Klaus




Home | Main Index | Thread Index