[cpp-threads] Implicit Synchronization

Peter Dimov pdimov at mmltd.net
Tue Jul 11 16:54:16 BST 2006


Doug Lea wrote:
> Lawrence Crowl wrote:
>> One of the things we must make sure we address is the implicit
>> syncronization that we expect in the data that we guard with
>> locks.  For example, with double-checked locking for sharing
>> variable initialization, we cannot define only the
>> synchronization on the locks, but also on the variable being
>> initialized.  Likewise, for reference-counted objects, we must
>> know that on (atomically) decrementing the count to zero,
>> reading the pointer must result in the value written.
>> 
> 
> This is a very good point, that we encounter all the time
> developing java.util.concurrent: You often need heavier
> barriers than you'd otherwise expect, to make sure that
> if some less-than-fully thread-safe object is, for example,
> placed in a hash table by one thread, that it is guaranteed
> readable by others retrieving it.
> 
> You can say all you want in specs that people shouldn't expect
> this to work, but they will, and so unless you do this part, users
> will encounter what they claim are bugs.

Why shouldn't people expect this to work?



More information about the cpp-threads mailing list