[asterisk-dev] (Possibly) Unnecessary futex calls

Shaun Ruffell sruffell at digium.com
Fri Feb 20 14:22:00 CST 2009


Benny Amorsen wrote:
> I can understand why all the recvfrom, sendto, and poll calls are
> there. However, what is pid 8947 doing?! It seems to be waking up
> because of a futex at least 25 times a second.
> 
> Why does it do that? The version is 1.6.1 beta 4 by the way, I really
> ought to upgrade to rc1.

I noticed something similar a while back.  It's related to the way 
asterisk does deadlock avoidance.  Look on line 19457 of:

http://svn.digium.com/view/asterisk/tags/1.6.1-beta4/channels/chan_sip.c

You can see asterisk will grab the netlock, try to grab the channel 
lock, and if it fails the channel lock, it will release the netlock, 
sleep a bit, then start the process over again.

What would be worth checking into is using the pthread_mutex_timedlock 
call, if available on the platform, everywhere the trylock..sleep 
pattern is used.




More information about the asterisk-dev mailing list