From owner-freebsd-current Sun Jul 11 15:50:51 1999 Delivered-To: freebsd-current@freebsd.org Received: from ducky.net (gate.ducky.net [199.2.211.252]) by hub.freebsd.org (Postfix) with ESMTP id E6D9314EE9 for ; Sun, 11 Jul 1999 15:50:47 -0700 (PDT) (envelope-from mike@ducky.net) Received: from ducky.net (localhost.ducky.net [127.0.0.1]) by ducky.net (8.9.1/8.8.5) with ESMTP id PAA16398; Sun, 11 Jul 1999 15:49:16 -0700 (PDT) Message-Id: <199907112249.PAA16398@ducky.net> To: Doug Rabson Cc: Matthew Dillon , Alan Cox , Stephen McKay , Andrew Gallatin , freebsd-current@freebsd.org, mike@ducky.net Subject: Re: "objtrm" problem probably found (was Re: Stuck in "objtrm") In-reply-to: Your message of "Sun, 11 Jul 1999 08:12:52 BST." Date: Sun, 11 Jul 1999 15:49:15 -0700 From: Mike Haertel Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >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 majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message