Martin,
it's exactly the corner cases that are difficult to get right and for which 
the completion_mutex was meant to exist. For example, what happens if more 
than one thread call Task::join? In that case, you call wait_for_all more 
than once. The mutex avoids this.

I would agree that the task itself may not have to deal with the mutex. In the 
case of threads, you need to do this because the thread that creates another 
thread may call join() before the new thread has even started to exist and 
has had its first CPU cycle (during which it copies function arguments from 
the caller), but I would trust that the TBB functions that schedule tasks get 
this right.

Can you explain what caused the problem with the completion_mutex in the tasks 
case? You say:

> It's the 'completion_mutex' introduced by Task - somehow, all the
> threads try to acquire a mutex, and this blocks everything.

The way it is intended to work is of course that the worker task continues to 
run and at the end releases the mutex, which will then wake up the waiting 
tasks one-by-one. Are you suggesting that the waiting threads prevent the 
worker task from working?

Best
 W.

-------------------------------------------------------------------------
Wolfgang Bangerth                email:            [email protected]
                                 www: http://www.math.tamu.edu/~bangerth/

_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to