Subject: Re: Atomic ops API
To: Bang Jun-Young <junyoung@netbsd.org>
From: Johnny Billquist <bqt@softjar.se>
List: tech-kern
Date: 03/15/2007 09:51:36
Bang Jun-Young wrote:
> On 3/15/07, Johnny Billquist <bqt@softjar.se> wrote:
> 
>> Isn't the whole point of a function called "atomic_compare_and_store"
>> that it would be atomic? Otherwise I would say that it was misnamed.
>> So, it should not be possible for *target to be modified withing the
>> atomic_compare_and_store by some other entity, or the function isn't 
>> atomic.
>>
> 
> The atomic function means "a function that performs an atomic 
> operation", not
> "a funtion that is atomic itself."

Then I think the name is stupid, and furthermore, that means that the 
return value of the function is meaningless. It will not tell you 
anything. Instead you will always have to check after the operation 
wether it performed the swap or not. But that in itself will not answer 
the question wether the swap was performed or not either, since the 
value that you were supposed to write in case of a match might be the 
value that was already there.

So in essence, your implementation of atomic_compare_and_swap() or 
atomic_compare_and_store becomes a maybe_store(), without you being able 
to tell wether you did the store or not, and without being able to know 
what the value was before the operation.
What would be the point of this function?

	Johnny