Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2007-07-25 19:28:57


Baruch Zilber wrote:
> You are right.
> I fixed it and here is the new implementation:
>
> inline void atomic_increment( int * pw )
> {
> _Asm_fetchadd(_FASZ_W, _SEM_ACQ, (void*)pw, +1, _LDHINT_NONE);
> }
>
>
> inline int atomic_decrement( int * pw )
> {
> int r = static_cast<int>(_Asm_fetchadd(_FASZ_W, _SEM_ACQ,
> (void*)pw, -1, _LDHINT_NONE));
> if (1 == r)
> {
> _Asm_mf();
> }
>
> return r - 1;
> }

Hmm. Why did you switch to _SEM_ACQ? atomic_increment should use _REL
because it's rumored to be cheaper, and atomic_decrement needs to use _REL
for correctness.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net