[cpp-threads] Re: Exception propogation across threads
Vijay Saraswat
vijay at saraswat.org
Thu Feb 22 12:28:31 GMT 2007
Boehm, Hans wrote:
>>Unwind the stack, terminate the thread and throw some kind of
>>unexpected thread-death exception in the joining thread. Less
>>severe than (i) and (ii), less compiler magic or modification
>>of exceptions needed than
>>(iii) and (iv), and more usable than (v).
>>
>>
>>
>My recollection from the last discussion is that this has the (probably
>fatal?) flaw that the join may not be executed until next month. Thus
>you could effectively be hiding the exception for a month. Since it
>escaped the thread, it was presumably not completely handled, so we are
>now letting the application run in a bad state for a month, potentially
>wreaking all sorts of havoc.
>
>
>
A word about how we solved this in X10 (http://x10.sf.net) -- a language
in the Java framework focused on constructs for concurrency and
distribution.
We introduced a scoped join construct, finish S, where S is a statement.
The thread executing finish S runs S, and then waits for all threads
that were launched during the execution of S to terminate -- normally or
abruptly (by throwing an exception). Once all threads have terminated,
the set of exceptions (if any) thrown by the subservient threads is then
encapsulated in a single exception thrown in the parent thread.
Thus there are no race conditions. This works extremely well,
particularly for structured (nested) parallelism, as supported by Cilk
and X10. One can start the main program in a finish. Now there is a
thread at the very root of the "spawns" tree that can catch any cross
thread exception.
More details on the rooted exception model at p 22 of
http://x10.sourceforge.net/docs/x10-101.pdf
Best,
Vijay
--
X10: Programming parallel machines, productively (http://x10.sf.net)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.decadentplace.org.uk/pipermail/cpp-threads/attachments/20070222/e6fc32c1/attachment.html
More information about the cpp-threads
mailing list