Subject: Re: Atomic ops API
To: Ignatios Souvatzis <is@netbsd.org>
From: Jason Thorpe <thorpej@shagadelic.org>
List: tech-kern
Date: 03/13/2007 08:26:51
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"

> 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.

> 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?

-- thorpej