From: Dave Abrahams (abrahams_at_[hidden])
Date: 1999-12-26 18:34:17
> A compiler can legally implement this as (in pseudocode):
> treg1 := mem( *pn )
> treg2 := sub( treg1 - 1 )
> mem( *pn ) := treg2
> treg3 := mem( *pn )
> if( treg3 != 0 ) goto 1f
> ...delete px
> Note that if this is done, then 2 threads can both
> execute the decrement, and both arrive at the
> load into treg3 at the same time, leading to a double
> Now, most compilers will avoid the treg3 load,
> using the treg2 value in the compare,
> so that Dave's statement will be true on most systems.
> But, it doesn't have to be so. Which is half of the fun
> of multothreading, isn't it?
Andy's analysis notwithstanding, my statement will always be true unless 2
threads assign to the same smart_ptr simultaneously.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk