Subject: Re: Atomic ops API
To: Jason Thorpe <thorpej@shagadelic.org>
From: Johnny Billquist <bqt@softjar.se>
List: tech-kern
Date: 03/19/2007 11:09:09
Jason Thorpe wrote:
> 
> On Mar 16, 2007, at 2:21 AM, Johnny Billquist wrote:
> 
>> Jason Thorpe wrote:
>>
>>> Anyway, I've decided to stick with "cas" as "compare-and-store".
>>
>> I just came up with another question, by the way.
>> What is the intended use for this function? Is it mostly for  spinlocks?
>> If so, then I think we should try something else. For the VAX,  
>> implementing spinlocks is very easy, but they don't match the  
>> semantics of compare_and_swap or compare_and_store
> 
> No, not for spinlocks.  There do exist applications that might want a  
> compare-and-{store,swap}, and the CAS primitive is also used to  
> implement other atomic operations on many (most?) architectures (such  
> as atomic-increment, atomic-or, etc.)

Hmm. Isn't it then that we're either interested in the atomicity of the 
operation, and it that case, we're just interested in wether to swap 
took place or not, or we're interested in the return value as well, in 
which case we're not that dependant on it being atomic?
But having one operation for both uses is perhaps the wish?

	Johnny