Subject: Re: Test and set (was Re: postgreSQL)
To: Chris G. Demetriou <>
From: Bill Sommerfeld <>
List: tech-kern
Date: 05/26/1999 16:09:12
There are a variety of different atomic instructions out there.

To throw out one of the outliers in this space, PA has "compare and
clear" as its atomic memory access instruction.  This is sort of like
"test and set", except that the "set" state is zero, and the "unset"
state is non-zero.

To make life even more interesting, semaphores have to be 16-byte
aligned, though they're only 4 bytes wide.

I suspect a "sufficiently MI" interface to an "atomic_op()"-like thing
would have to abstract what the "set" and "reset" values and type look

    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.

					- Bill