>On Sat, 10 Jul 1999, Matthew Dillon wrote:
>> 
>>     The supposedly atomic functions in i386/include/atomic.h are not
>>     as atomic as was previously thought :-):
>> 
>> #define atomic_add_short(P, V)          (*(u_short*)(P) += (V))
>[...]
>
>Before I fixed this stuff for the alpha, the += expressions were
>scattered all over the source tree. At least you get to fix the macro :-).

Um.  FYI on x86, even if the compiler generates the RMW
form "addl $1, foo", it's not atomic.  If you want it to
be atomic you have to precede the opcode with a LOCK
prefix 0xF0.

I guess I should clarify what I mean by atomic:

"addl $1, foo" is atomic with respect to interrupts.
However, it is not atomic with respect to other processors,
i.e is not SMP safe.

"lock addl $1, foo" is both atomic with respect to
interrupts, and also with respect to activity by
the other processor.

        Mike
        (one of those pesky x86 architects at Intel)


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to