[cpp-threads] Alternatives to SC

Jeremy Manson jmanson at cs.umd.edu
Thu Jan 11 19:31:44 GMT 2007


Herb Sutter wrote:

> 1. What are we giving up? To answer that, we need to be clear about
> how much allowing IRIW may surprise programmers.

So, I've looked into this a little, in terms of reviewing various design 
patterns that use volatile in Java.  I have yet to see anything that 
isn't written by people who are absolute experts in this field that 
works with SC and doesn't work with IRIW.  Those that do seem to be toy 
examples.

I suspect that were we to adopt IRIW, we would end up giving programmers 
provably safe boxes to play in (as we do with non-volatile fields).  We 
will end up saying things like "you don't have to worry about reordering 
accesses when you aren't dealing with more than one volatile at the same 
time -- if you do, then things can get kind of hairy" and "you can use 
IRIW to make the double-checked locking idiom work".

Programmers generally seem okay with this.  I had more to say on that 
topic, but it sort of drifted off-topic, so I deleted it.  :)

Of course, in C++, YMMV.  Offhand, it seems to me that the C++ model 
seems to be able to take more, not less, complication, because of all of 
the various oddball C++ issues you don't actually get in Java.

					Jeremy



More information about the cpp-threads mailing list