[mythtv] [mythtv-commits] Ticket #3517: Improvements to ProcessRequestThread pool handling in the MainServer of MythBackend

Mark Buechler mark.buechler at gmail.com
Thu Jul 5 13:17:22 UTC 2007

May I ask what inspired this patch? I've seen issues which may have been
fixed with this patch and was wondering if you'd seen the same.

- Mark.

On 5/27/07, MythTV <mythtv at cvs.mythtv.org> wrote:
> #3517: Improvements to ProcessRequestThread pool handling in the
> MainServer of
> MythBackend
> --------------------------------------------------------+-------------------
> Reporter:  Russell Bryant <russell at russellbryant.net>  |       Owner:  ijr
>      Type:  patch
> |      Status:  new
> Priority:  minor                                       |
> Milestone:  unknown
> Component:  mythtv                                      |
> Version:  unknown
> Severity:  medium                                      |
> --------------------------------------------------------+-------------------
> The attached patch provides some improvements to the handling of the
> request processing thread pool in the MainServer of MythBackend.
>   * In the ProcessRequestThread class, both the setup() and killit()
> functions unlocked the mutex before signalling the wait condition.  The
> patch moves the unlock to be *after* the condition is signalled, to remove
> the possibility of a race condition between the thread waiting on the
> condition and the thread signaling the condition.
>   * The rest of the changes rework the way a thread is acquired from the
> thread pool.  I will explain the previous behavior, as well as the
> behavior after the patch.
> === Previous Behavior ===
> The code created a timer and checked the container of idle threads once
> every millisecond, locking and unlocking the mutex each time, until a
> thread was acquired.  If a thread was not acquired after a total of 10 ms,
> it would create a new one.
> When creating a new thread, the code would wait 50 ms to attempt to ensure
> that the new thread is up and running before continuing.
> === New behavior ===
> The code attempts to retrieve a thread from the thread pool.  If one is
> not available, it uses a thread condition to wait for up to 10 ms until
> one becomes available.  When threads become available, this condition is
> signaled to wake up anyone waiting on an idle thread.
> Also, when a ProcessRequestThread is created, it uses a thread condition
> to wait for the thread to be up and running.  This both ensures that the
> code does wait long enough, and also doesn't wait any longer than it needs
> to.
> Also, in the MainServer constructor, it now uses this thread condition to
> ensure that each thread created for the thread pool is running before
> moving on.  Previously, this check was not done here.
> --
> Ticket URL: <http://svn.mythtv.org/trac/ticket/3517>
> MythTV <http://svn.mythtv.org/trac>
> MythTV
> _______________________________________________
> mythtv-commits mailing list
> mythtv-commits at mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mythtv.org/pipermail/mythtv-dev/attachments/20070705/425e9151/attachment-0001.htm 

More information about the mythtv-dev mailing list