[cpp-threads] Asynchronous Execution Issues

Doug Lea dl at cs.oswego.edu
Sat Apr 25 18:48:49 BST 2009


Boehm, Hans wrote:
> 
> I'm not quite sure I understand exactly which one of several problem
> scenarios you're worried about here.  Presumably the child thread sets the

Me neither, but...

> promise, and then exits without additional library calls.  I think the intent
> was to make a thread that behaves this way (i.e. that makes a synchronization
> call to the library to indicate it is done and then exits) safe in the sense
> that it is guaranteed not to race with destruction of static objects needed
> by the standard library (guarantee A).  

... it's worth pointing out one solution for one of the
possible problems, so-called "type-stable memory".
This is just the idea of never deleting some state,
but still being able to reuse it, because reuse in the
context of a new thread is harmless even if the
supposed target of the operation is a now-dead thread.
If you can maintain this weird-but-harmless property,
you end up needing only as many of these
state-holders as max #threads that have ever co-existed.
This is used for example in openjdk/hotspot to maintain
per-thread semaphore-like objects for implementing park/unpark
(which is possible because park is spec'ed to allow
spurious wakeups).

-Doug



More information about the cpp-threads mailing list