Subject: Re: Test and set (was Re: postgreSQL)
To: Simon Burge <simonb@netbsd.org>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 05/28/1999 10:34:04
On Fri, 28 May 1999 17:36:43 +1000 
 Simon Burge <simonb@netbsd.org> wrote:

 > >     atomic_value_t v1 = ATOMIC_INIT_RESET;
 > >     atomic_value_t v2 = ATOMIC_INIT_SET;
 > > 
 > >     int atomic_set(atomic_value_t *v);
 > > 	set *v; return 1 if it wasn't already set.
 > >     void atomic_reset(atomic_value_t *v);
 > > 	reset *v.
 > >     int atomic_isset(atomic_value_t *v);
 > > 	return 1 if *v is set, otherwise 0.
 > 
 > And this interface would live in <atomic.h> or <sys/atomic.h>?  If
 > we need a kernel implementation (as for older MIPS chips), then
 > <sys/atomic.h> would be the way to go...
 > 
 > I'll put together a full proposal.

<machine/atomic.h> is the right thing, I think, since it's inherently
machine-dependent.

Also note some of the atomic operations that arch/alpha/alpha/atomic.s
implements...

	- atomic test-and-set (for spin locks)

	- atomic load-and-latch (for atomically reading a counter and
	  resetting it to zero, for example)

        -- Jason R. Thorpe <thorpej@nas.nasa.gov>