[Haskell-cafe] Re[2]: Parallel combinator, performance advice

Bulat Ziganshin bulat.ziganshin at gmail.com
Tue Apr 7 11:22:55 EDT 2009

Hello Neil,

Tuesday, April 7, 2009, 6:13:29 PM, you wrote:

> Consider a thread pool with 2 threads and the call parallel_ [parallel_ [b,c],a]

> You get the sequence:
> enqueue (parallel_ [b,c])
> a
> wait on parallel_ [b,c]

> While you are executing a, a thread pool starts:
> enqueue b
> c
> wait for b

> Now you have all the threads waiting, and no one dealing with the
> thread pool. This results in deadlock.

i think the only way to solve this problem is to create one more
thread each time. let's see: on every call to para you need to alloc
one thread to wait for jobs completion. so on each nested call to para
you have minus one worker thread. finally you will eat them all!

so you need to make fork: one thread should serve jobs and another one
wait for completion of this jobs bucket. and with killItself flag you
will finish superfluous thread JIT

Best regards,
 Bulat                            mailto:Bulat.Ziganshin at gmail.com

More information about the Haskell-Cafe mailing list