On Sun, 11 Jul 1999, Mike Haertel wrote:
> >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.
I know about this. We (currently) only need it to be atomic wrt interrupts
and the i386 header file states this explicitly. The alpha versions of
this are SMP safe simply because the code sequence which was interrupt
safe was the same.
--
Doug Rabson Mail: [EMAIL PROTECTED]
Nonlinear Systems Ltd. Phone: +44 181 442 9037
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message