Subject: Re: Atomic ops API
To: Jason Thorpe <thorpej@shagadelic.org>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-kern
Date: 03/13/2007 16:43:50
On Tue, Mar 13, 2007 at 08:26:51AM -0700, Jason Thorpe wrote:
>
> On Mar 13, 2007, at 8:18 AM, Ignatios Souvatzis wrote:
>
> >On Tue, Mar 13, 2007 at 08:16:10AM -0700, Jason Thorpe wrote:
> >
> >>Oh, and dunno... m68k called it "compare-and-set" long before Solaris
> >>called it "compare-and-swap"
> >
> >I was pretty sure until you wrote that (but have my books at home)
> >that CAS is compare and swap.
>
> Hm, if it is compare-and-swap, then great... but I thought it was
> compare-and-set. Anyway, if you could double-check for me, that would
> be great -- m68k is one of the platforms I was thinking of when I went
> with "compare-and-store"
I'll do.
> >Note that CAS2 needs a trap on 68060, and CAS needs a trap if
> >unaligned.
>
> The API will specify that behavior is undefined if access is
> unaligned. So we won't have to worry about fixing up unaligned access.
Ah, that's ok. I don't remember whether we have the emulation code in our
kernel... and anyway, it would be slooow.
There's another problem on Amiga, though. Officially, Amiga machines aren't
expected to run the bus cycles to implement CAS correctly. I suspect that's
a very-low-end-machine problem (read: real chip mem) only, and that cached
memory would be ok. Will have to check that.
> >OTOH, if we don't have SMP machines, it's easier, right?
>
> Sure, you could always do a cas-as-ras as the base primitive and put
> everything on top of that (that's what I did for ARM). But if you can
> do it in a short sequence of instructions, then that's probably faster
> and thus preferable, yes?
Right.
-is