Subject: Re: vax needs atomic ops
To: Andrew Doran <ad@netbsd.org>
From: Johnny Billquist <bqt@softjar.se>
List: port-vax
Date: 12/10/2007 11:24:35
Well, if someone can fix the latest gcc, which broke the VAX again, I could
maybe look at this.
(But why do you want compare-and-swap? Why wouldn't compare-and-set suffice?)
Johnny
Andrew Doran skrev:
> 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.
--
Johnny Billquist || "I'm on a bus
|| on a psychedelic trip
email: bqt@softjar.se || Reading murder books
pdp is alive! || tryin' to stay hip" - B. Idol