Mailing List archive

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

[vdr] Re: vdr 1.3.18 cCondWait::SleepMs



ludwig.nussel@gmx.de(Ludwig Nussel)  15.01.05 23:42


>Klaus Schmidinger wrote:
>> Ludwig Nussel wrote:
>>>Klaus Schmidinger wrote:
>>>>Wherever it is feasible VDR does wait on conditions.
>>>
>>> [...]
>>>-                 cCondWait::SleepMs(1); // this keeps the CPU load
>>>low +                 playMode_condition.Wait(mutex);
>>> [...]
>>
>> Why so complicated?
>> All that needs to be done is to wait a little while at this point,
>> making sure the time slice will be given up. It doesn't really
>> matter whether we wait 1, 2 or 3 milliseconds - even 10 would be ok
>> here.

>You said "Wherever it is feasible VDR does wait on conditions" which
>obviously is not true in the above case. What has to be done here is
>not to wait for time to pass but to wait for playmode to change. No
>matter how long you make the sleep it will still be busy waiting. So
>instead of causing useless context switches all the time (while
>still holding the lock!) you can just suspend the execution of the
>thread until Play() changes the playmode. A condition variable looks
>exactly like the right tool for that job.

ACK.
But if you look higher in the loop, there are several other
variables beeing polled too!
That maybe the reason, why no real suspend is done here.

IMHO: "normally" all threads should wait "at" something, a "mutex" or a 
"condition" or a "queue" or a "mailbox" or a "fifo" or....
But if you look in VDR, most/many (have not counted) threads 
seems to be "waiting" in a sleep.
That costs time, consumes power and makes the software slow.

Rainer





Home | Main Index | Thread Index