C++ Threading Proposal

Boehm, Hans hans.boehm at hp.com
Mon Sep 27 20:20:14 BST 2004


My understanding of the Ada model (based also on a 1994 draft of the standard) is that it's actually pretty good for the time.  It differs from the Java approach in several ways:

1) Writes to a field are allowed to "interfere with" at least other fields in that object.  I currently think this is a mistake given current hardware capabilities and the existing difficulties of writing multithreaded code.  It was a reasonable choice in 1994.

2) A concurrent write and other access (a race) is viewed as an error, just like the Pthread model.    Unlike in the Java setting where this creates security issues, this is OK for many C++ programs.  But it doesn't address lock-free algorithms, which was a big part of our motivation.

3) It uses guards on entry to a "protected procedure" (roughly "synchronized method" in Java) instead of condition variables.  I gather that these are typically repeatedly evaluated on exit from protected procedures?  I think I mildly prefer explicit condition variables (roughly as in Pthreads, though I don't fully understand the tradeoffs as to whether or not a notification should hold the lock) to either this or the Java model, since I think it makes performance a bit more transparent.

4) It's a bit clearer than the Pthread model about visibility rules, but not as clear as I would like.  It's a bit more of a stretch to argue that my register promotion example is legal in Ada, but it's not as clearly prohibited as I would like.

5) It doesn't seem to address atomic memory operations or "unscoped" e.g. conditionally acquired locks.

My general inclination is still to try for as much commonality as reasonable between Java and C++, since many programmers will need to deal with both.

Hans

> -----Original Message-----
> From: Andrei Alexandrescu [mailto:andrei at metalanguage.com]
> Sent: Saturday, September 25, 2004 2:21 PM
> To: Ben Hutchings; Hans Boehm; Kevlin Henney; Bill Pugh; Douglas C.
> Schmidt; Doug Lea
> Cc: Jim Rogers
> Subject: Fwd: Re: C++ Threading Proposal
> 
> 
> Jim  Rogers  (cc'd)  sent  me some examples of using Ada's concurrency
> mechanisms, for possible inspiration.
> One   is   attached   in   text   format,   and   the   other   is  at
> http://home.att.net/~jimmaureenrogers/Shared_Resource_Design_P
> atterns.html.
> I  am sending this to you FYI, and am also adding the documents to our
> nascent institutional memory.
> Andrei
> This is a forwarded message
> From: Jim Rogers <jimmaureenrogers at att.net>
> To: "Andrei Alexandrescu" <andrei at metalanguage.com>
> Date: Monday, September 20, 2004, 9:13:24 PM
> Subject: C++ Threading Proposal
> ===8<==============Original message text===============
> Hello Andrei,
> The attached file is a simple text file containing an example of Ada
> tasking.
> I used the attachment because my email tool was mangling my 
> formatting.
> Jim Rogers
> ===8<===========End of original message text===========
> -- 
> Best regards,
>  Andrei                            mailto:andrei at metalanguage.com
> 






More information about the cpp-threads mailing list