[mythtv] usleep(), busy wait and FreeBSD

Geoffrey Hausheer ou401cru02 at sneakemail.com
Tue Sep 2 16:24:24 EDT 2003


On Tue, 2 Sep 2003 15:18:45 -0400, "Isaac Richards ijr-at-po.cwru.edu
|mythtv/1.0-Allow|" <e6kbhbk35r0t at sneakemail.com> said:
> > a) Is there a reason why synchronization in mythtv is implemented with
> >    busy waits and not with condition variables ?
> 
> Easier the way it is, really.  I wouldn't be adverse to a patch to
> convert 
> things to condition variables, though.

Just my two cents.  When I switched from a busy-wait to
condition-variable implementation in the transcoder, the performance
improvement was about 30% (of course that was in a case where blocking is
expected to happen extremely often).  The problem with using condition
variables, is that it is easy to introduce deadlocks if you aren't very
careful.  this can be mitigated using pthread_cond_wait_timeout, but the
implementation of that function is not always very efficient, depending
on the OS.  Anyhow, in my opinion, switching to cond variables would be
cool, but since (a) most places where busy-loops are used aren't actually
expected to block too frequently, so the performance gain is probably
negligable, and (b) it means that due diligence will be needed for all
future patches, as a lot of people aren't pthread gurus (myself
included), and it is really easy to screw things up (as I've learned many
times in the past).

.Geoff


More information about the mythtv-dev mailing list