[libdispatch-dev] Experimental Pthread Work Queue Support for FreeBSD

Robert Watson rwatson at FreeBSD.org
Thu Dec 24 11:25:34 PST 2009


On Tue, 15 Dec 2009, David Leimbach wrote:

> Thanks for clarifying!  That's very exciting!  I really like some things 
> about libdispatch and am glad to see it being embraced for more than just 
> Mac OS X.

There appear to be lots of technical upsides to adopting this approach, but as 
the pthread work queue API is non-public in Mac OS X, we should think fairly 
hard about the forward API considerations.  On the other hand, this is a great 
chance for Apple to get feedback on how well it works via second independent 
implementation :-).  From chatting with Stacey offline, I know he's considered 
a number of variations on the Apple approach, so it inspires some amount of 
confidence that he's concluded the Apple one was the best one.

I'm in the process of doing a bit of application work that will allow me to do 
some performance measurement on a popular threaded application.  This will 
alow me to make some comparisons along a number of dimensions: FreeBSD<->Mac 
OS X, GCD<->pthread worker pool, and also now the internal GCD thread pool vs 
pthread work queue approaches.  It will probably be a couple of weeks before I 
have anything to present, but will follow up to the list once there's 
something real to report.

Robert N M Watson
Computer Laboratory
University of Cambridge

> 
> Dave
> 
> On Tue, Dec 15, 2009 at 12:40 PM, Stacey Son <sson at freebsd.org> wrote:
>       Hi,
> 
> Robert was the one that asked me if I could look into this so
> hopefully he has not already done this...  :)
> 
> Currently the GCD port for FreeBSD uses the user-level thread worker
> code in libdispatch and not the pthread_workqueue_*_np() calls like
> darwin.   The pthread work queue code below pretty much follows the
> same idea that darwin uses.   It is a kernel assisted thread pool
> implementation. The kernel manages the creation and destruction of
> threads in the work pool based on if it sees lots of the worker
> threads blocking, being idle for a (relatively) long time, etc.   I
> don't know if it performs any better than the user-level thread pool
> since I have not yet done any performance testing. 
> 
> Best Regards,
> 
> -stacey.
> 
> 
> On Dec 15, 2009, at 1:26 PM, David Leimbach wrote:
>
>       I think Robert Watson has already done this?
> My understanding is that 8-STABLE supports this.
> 
> Am I wrong?
> 
> Dave
> 
> On Tue, Dec 15, 2009 at 8:09 AM, Stacey Son <sson at freebsd.org>
> wrote:
>       Hi All,
>
>       Just in time for the holidays I have created a
>       couple of patches for FreeBSD-Current to add
>       apple-like pthread workqueues.   You can find the
>       patches at:
>
>              http://people.freebsd.org/~sson/thrworkq/
>
>       The first patch (kern_thrworkq_*.diff) adds the
>       kernel support and thr_workq() system call.  To
>       compile it into the kernel "options THRWORKQ" needs
>       to be added to the kernel config file.  The second
>       patch (pthread_workqueue_*.diff) is for the libthr
>       code and adds the pthread_workqueue_*_np()
>       functions.  (See
>       http://people.freebsd.org/~sson/thrworkq/pthread_workqueue.3.txt
>       for the man page.)   I have only done a limited
>       amount of testing so I am sure there are bugs.   Any
>       questions, comments, bug reports, and/or patches are
>       welcomed.
>
>       Thanks,
>
>       -stacey.
>       _______________________________________________
>       libdispatch-dev mailing list
>       libdispatch-dev at lists.macosforge.org
>       http://lists.macosforge.org/mailman/listinfo.cgi/libdispatch-dev
> 
> 
> 
> 
> 
>


More information about the libdispatch-dev mailing list