Subject: vax needs atomic ops
To: None <port-vax@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: port-vax
Date: 11/29/2007 15:46:34
Hi,
We're nearly ready with atomic ops in the kernel, however the code for vax
needs to be written. The minimum that needs to be provided is an atomic
compare and swap function and the rest can be provided by C code.
There is already and atomic compare and _set_, for the reader/writer locks
in lock_stubs.S. The description of how the CAS function should behave is
below. It needs to be known by a few different names, this is from the arm
port:
STRONG_ALIAS(_atomic_cas_ulong,_lock_cas)
STRONG_ALIAS(atomic_cas_ulong,_lock_cas)
STRONG_ALIAS(_atomic_cas_32,_lock_cas)
STRONG_ALIAS(atomic_cas_32,_lock_cas)
STRONG_ALIAS(_atomic_cas_uint,_lock_cas)
STRONG_ALIAS(atomic_cas_uint,_lock_cas)
STRONG_ALIAS(_atomic_cas_ptr,_lock_cas)
STRONG_ALIAS(atomic_cas_ptr,_lock_cas)
Any takers?
Thanks,
Andrew
uint32_t
atomic_cas_32(volatile uint32_t *ptr, uint32_t old, uint32_t new);
DESCRIPTION
The atomic_cas family of functions perform a compare-and-swap operation
in an atomic fashion. The value of the variable referenced by ptr is
compared against old. If the values are equal, new is stored in the
variable referenced by ptr.
The old value of the variable referenced by ptr is always returned
regardless of whether or not the new value was stored. Applications can
test for success of the operation by comparing the return value to the
value passed as old; if they are equal then the new value was stored.