[Asterisk-Dev] busy-wait loops in pbx_dundi

Luigi Rizzo rizzo at icir.org
Fri Jun 10 07:06:10 MST 2005


On Fri, Jun 10, 2005 at 09:55:59AM -0400, Steve Kann wrote:
...
> DOH! I had an off by 1000 error on my head :) -- was thinking that 
> usleep took milli, not micro-seconds.
> 
> In general, though, usleep(1) will at the very least cause a thread to 
> yield, even if it doesn't wait until the next timer tick to get 
> re-activated. If the condition is waiting for some kind of lock, which 

unfortunately in the specific case the condition is not waiting
for a lock, but waiting for actual work being done (signalled by
putting some struct on a list, which requires scanning the list
to be verified, so it's not even granted that the check is
cheap).

As a matter of fact, it would not make sense to usleep waiting
for a lock, unless you have a broken (read: deadlock prone)
locking scheme....

> presumably isn't being held by something blocking on i/o, then that kind 
> of loop doesn't seem dangerous..

anyways, i hope you get my point when i say "dangerous":
in two emails, you have made two assumption which are perfectly
reasonable in principle, but unfortunately do not match what the
code really does :)

	cheers
	luigi


> -SteveK
> 
> _______________________________________________
> Asterisk-Dev mailing list
> Asterisk-Dev at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-dev
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev



More information about the asterisk-dev mailing list