[Home]

Summary:ASTERISK-12328: [patch] find_idle_thread() uses spin wait
Reporter:Peter Grayson (jpgrayson)Labels:
Date Opened:2008-07-07 14:01:59Date Closed:2008-11-04 16:52:04.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_iax2
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) chan_iax2_find_idle.patch
Description:When find_idle_thread() creates a new dynamic thread, it spins waiting for the newly created thread to "signal" that it is up, running, and ready to go. On a lightly loaded system, the child thread will be scheduled promptly and the parent thread will thus probably not spin too much.

On a heavily loaded system, it might be possible for the parent thread to be rescheduled many times prior to the child thread becoming ready. This is a waste of CPU when the system can least afford it.

Instead of spin waiting, a condition variable can be used. This would make the parent thread efficiently block until the child thread becomes ready.
Comments:By: Peter Grayson (jpgrayson) 2008-07-07 14:11:33

The attached patch replaces the find_idle_thread() spin wait with a condition variable.

Note that this also removes the odd-ball use of bitfield with the ready_for_signal variable.

By: Russell Bryant (russell) 2008-10-06 08:46:13

The patch looks good.  Someone just needs to update it to trunk and then it can be applied.

By: Digium Subversion (svnbot) 2008-11-04 16:52:02.000-0600

Repository: asterisk
Revision: 154428

U   trunk/channels/chan_iax2.c

------------------------------------------------------------------------
r154428 | tilghman | 2008-11-04 16:52:02 -0600 (Tue, 04 Nov 2008) | 7 lines

Switch to using a thread condition to signal that a child thread is ready for
work, rather than a busy wait.
(closes issue ASTERISK-12328)
Reported by: jpgrayson
Patches:
      chan_iax2_find_idle.patch uploaded by jpgrayson (license 492)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=154428