Re: Atomic ops API

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Johnny Billquist
Date: Thursday, March 15, 2007 - 9:23 am

Bang Jun-Young wrote:

Yes, nobody would probably write it in C, for various reasons.
But it wasn't an if that was missing in the concept, it was a lock.


If Jason understood you, then I guess we should all be happy. The reason 
I didn't understand you was because your conceptual implementation was 
broken. :-)

If we were to describe conceptually, without worrying about the fact 
that it wouldn't work, then I'd write it like this:

uint32_t compare_and_swap(uint32_t *target, uint32_t cmp, uint32_t new)
{
   uint32_t old = *target;
   if (*target == cmp) *target = new;
   return old;
}

But that also does away with the whole issue about choosing between 
compare_and_swap() and compare_and_store() since that is about wether 
one would be easier in general to implement on machines. Obviously, from 
this conceptual description, either would be just as easy.

But I'm happy to leave it at that. Just call me stupid. :-)

	Johnny
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Atomic ops API, Jason Thorpe, (Mon Mar 12, 11:28 pm)
Re: Atomic ops API, SODA Noriyuki, (Mon Mar 12, 11:55 pm)
Re: Atomic ops API, Joerg Sonnenberger, (Tue Mar 13, 5:41 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 8:14 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 8:16 am)
Re: Atomic ops API, Ignatios Souvatzis, (Tue Mar 13, 8:18 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 8:26 am)
Re: Atomic ops API, Martin Husemann, (Tue Mar 13, 8:27 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 8:36 am)
Re: Atomic ops API, Ignatios Souvatzis, (Tue Mar 13, 8:43 am)
Re: Atomic ops API, Andrew Doran, (Tue Mar 13, 8:49 am)
Re: Atomic ops API, Brian Ginsbach, (Tue Mar 13, 8:53 am)
Re: Atomic ops API, tlaronde, (Tue Mar 13, 9:17 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 9:31 am)
Re: Atomic ops API, Joerg Sonnenberger, (Tue Mar 13, 9:31 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 9:33 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 9:34 am)
Re: Atomic ops API, jonathan, (Tue Mar 13, 9:35 am)
Re: Atomic ops API, Ben Harris, (Tue Mar 13, 9:36 am)
Re: Atomic ops API, jonathan, (Tue Mar 13, 9:49 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 9:58 am)
Re: Atomic ops API, Jonathan Stone, (Tue Mar 13, 10:02 am)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 10:05 am)
re: Atomic ops API, matthew green, (Tue Mar 13, 12:56 pm)
Re: Atomic ops API, Bang Jun-Young, (Tue Mar 13, 5:42 pm)
Re: Atomic ops API, Bang Jun-Young, (Tue Mar 13, 5:52 pm)
Re: Atomic ops API, Jason Thorpe, (Tue Mar 13, 8:10 pm)
Re: Atomic ops API, Johnny Billquist, (Wed Mar 14, 5:18 am)
Re: Atomic ops API, SODA Noriyuki, (Wed Mar 14, 6:13 am)
Re: Atomic ops API, SODA Noriyuki, (Wed Mar 14, 6:17 am)
Re: Atomic ops API, Jason Thorpe, (Wed Mar 14, 9:11 am)
Re: Atomic ops API, Bang Jun-Young, (Wed Mar 14, 10:44 am)
Re: Atomic ops API, Johnny Billquist, (Wed Mar 14, 11:39 am)
68k CAS (was: Atomic ops API), Edgar , (Wed Mar 14, 1:32 pm)
Re: 68k CAS (was: Atomic ops API), David Laight, (Wed Mar 14, 2:59 pm)
Re: Atomic ops API, Bang Jun-Young, (Wed Mar 14, 5:17 pm)
Re: Atomic ops API, Johnny Billquist, (Thu Mar 15, 1:51 am)
Re: Atomic ops API, Bang Jun-Young, (Thu Mar 15, 5:38 am)
Re: Atomic ops API, Johnny Billquist, (Thu Mar 15, 5:54 am)
Re: Atomic ops API, Bang Jun-Young, (Thu Mar 15, 7:06 am)
Re: Atomic ops API, Johnny Billquist, (Thu Mar 15, 7:40 am)
Re: Atomic ops API, Bang Jun-Young, (Thu Mar 15, 8:43 am)
Re: Atomic ops API, Johnny Billquist, (Thu Mar 15, 9:23 am)
Re: Atomic ops API, Jason Thorpe, (Thu Mar 15, 9:24 am)
re: Atomic ops API, matthew green, (Thu Mar 15, 11:26 am)
Re: Atomic ops API, Jason Thorpe, (Thu Mar 15, 11:54 am)
Re: Atomic ops API, Johnny Billquist, (Fri Mar 16, 2:21 am)
Re: Atomic ops API, Johnny Billquist, (Fri Mar 16, 2:25 am)
Re: Atomic ops API, Jason Thorpe, (Fri Mar 16, 8:50 am)
Re: Atomic ops API, Ignatios Souvatzis, (Fri Mar 16, 8:51 am)
Re: Atomic ops API, Jason Thorpe, (Fri Mar 16, 8:51 am)
Re: Atomic ops API, David Laight, (Fri Mar 16, 9:01 am)
Re: Atomic ops API, Johnny Billquist, (Mon Mar 19, 3:09 am)