Thread Subcommittee Minutes from Berlin
N2012=06-0082, 2006-04-18, Lawrence Crowl
In wide-ranging discussions,
the thread subcommittee asked and answered
a number of questions about how to introduce threads into C++.
|Are threads hierarchical?
||No, use OpenMP.|
|Are threads flat peer-to-peer?
||Not completely, some management tasks become difficult.|
|Is there a master thread?
||Yes, it executes main.|
|Are threads compatible with the system?
||Yes. Anything else will be perceived as less than helpful.|
Creation and Termination
|Shall threads be explicit?
|Are threads coarse-grained?
|Is thread creation dynamic?
|If so, is it program controlled?
|Is work explicitly asigned to threads?
|Can one call exit only from the master thread?
||Yes, calling exit from a non-master thread induces an abort.|
|What happens when exit is called while threads are detached?
||The result is implementation-defined.|
|Is there a join operation?
|Are exceptions propogated through the join?
||Yes, otherwise they become unmanagable.
This propogation requires syntax or library ABI magic.
|Should there be a join any or join all?
||Not in the base layer, leave it to higher layers.|
|How are thread objects allocated?
||Dynamically, on the heap.
Thread objects on the stack are problematic
if an exception deletes the object,
better perhaps is dynamic allocation of the exception object.|
|May threads be detached?
||Yes, it means there will be no join operation
and the thread object may delete itself
on return from the thread function.|
|Does the master construct all globals variables?
||Maybe. The issue is a dlopen from a non-master thread
and the subsequent initialization of globals.|
|Shall we require dlopen only from a master thread?
||No, this inhibits MT-hot libraries.|
|Shall the implementation serialize all dlopens?
||Leave this implementation-defined.|
|Shall we prohibit calling dlopen while holding a lock?
||No, this approach violates encapsulation in the library.|
|Are recursive dlopens defined on different libries?
|Must non-recursive dlopens be serialized by user code?
Communication and Synchronization
|Is communication via message?
||No, use MPI.|
|Is communication via shared memory?
|Is synchronization via locks?
|If so, events or condition variables?
||Condition variables. They are much easier to use.|
|Can threads synchronize between processes?
||Make possible, but not defined.|
|Can threads synchronize with system threads?
|Can threads obtain handles on system threads?
||Yes, for scheduling.|
|Are static-duration variables synchronizable?
|Are static-duration variables explicitly synchronized,
e.g. __synchronized keyword?
||Maybe. The issue is that it might be better
if they were all implicitly synchronized.|
|Are locks in a library?
||Yes, there is a substantial variety.|
|Is progress guaranteed?
|Are scheudling hints available?
||Maybe. Revisit this issue.|
|Can one call terminate/abort anywhere?
||Yes, and terminate immediately.|
|Can a thread cancel itself?
|Can a thread cancel other threads synchronously?
|Can a thread cancel other threads asynchronously?
||No, this does terrible damage to code generation.|
|Can a thread suspend itself?
|Can a thread suspend others?
|Can a thread yield itself?
|Can a thread yield other threads?
|Is there a __thread keyword?
|May function-local thread-local variables
be dynamically initialized?
|May other thread-local variables be dynamically initialized?