Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-08-31 11:57:56

--- In boost_at_[hidden], "Jeff Paquette" <paquette_at_m...> wrote:
> at the assembly level, a 32 bit read is indeed atomic. However, I
do not
> believe that:
> int a, b;
> a = b;
> is guaranteed to be atomic. Any interrupt / task switch can occur
> the fetch of b and the store to a. That is:
> mov eax, [b] ;;; pseudo x86 assembly - nits not wanted.
> mov [a], eax

Makes sense to me. It's been a while since I dabbled in Assembly (10
years, to be exact). Doesn't x86 allow you to do a mov on memory
only, with out the register? If not, the claim by the Win32
documentation is very misleading. By "simple reads and writes" they
mean that:

a = 3;
if (a == 3)...

are atomic, but

a = b;
if (a == b) ...

are not. No wonder I've always been told to use
InterlockedExchange ;).

Bill Kempf

Boost list run by bdawes at, gregod at, cpdaniel at, john at