Boost logo

Boost :

Subject: Re: [boost] [threadpool] new version v12
From: k-oli_at_[hidden]
Date: 2008-11-01 15:14:48


Am Samstag, 1. November 2008 19:35:23 schrieb Vicente Botet Escriba:
> IMO, the implementation of the fork/join semantics do not need fibers.
> The wait/get functions can call to the thread_pool scheduler without
> context-switch. Which are the advantages of using fibers over calling
> recursively to the scheduler?

Fork/join semantics means: a taks creates a tree ov several sub-tasks
(forking) and uses the results of this sub-tasks for its computiations
(joining).

You know the recursive algorithm for calculating fibonacci numbers - each task
would insert two new sub-task in the scheduler until (n==0 or n==1) - it
creates a tree of sub-tasks each caculating a fibonacci number.
Because you have to wait for the result of
fibonacci(n)=fibonacci(n-1)+fibonacci(n-2) you would blockallwork-threads if
the tree of sub-task becomes too large (original n).

Please take alook into the example folder of threadpool. You will find two
exmaples for recursivly calculate fibonacci. Configure the pool with
tp::fibers_disabled and try to calulate fibonacci(3) with two worker-threads.
Your application will block forever.
Use the option tp::fiber_enabled and you can calculate any fibonacci number
without blocking

Oliver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk