UCAS(9) | Kernel Developer's Manual | UCAS(9) |
ucas
—
#include <sys/systm.h>
int
ucas_ptr
(volatile
void *uptr, void
*old, void *new,
void *retp);
int
ucas_int
(volatile
int *uptr, int old,
int new,
int *retp);
Except that they can be safely used for the kernel to access user-space address, they are semantically equivalents of atomic_cas(3).
ucas
functions are implemented in
machine-independent code, but rely on machine-dependent code to implement
optimized primitives, if possible.
The basic ucas
primitives have the
following signatures and are considered private to the implementation and
are not to be called by consumers of the ucas
API:
_ucas_32
(volatile uint32_t
*uptr, uint32_t old, uint32_t
new, uint32_t *retp);_ucas_64
(volatile uint64_t
*uptr, uint64_t old, uint64_t
new, uint64_t *retp);If a platform is able to provide a CAS operation that meets the
following criteria, it should define
__HAVE_UCAS_FULL
in
<machine/types.h>
and
provide complete machine-dependent implementations of
_ucas_32
() (and _ucas_64
(),
if an _LP64
platform):
If __HAVE_UCAS_FULL
is not defined, than a
generic implementation will be provided by machine-dependent code. This
generic implementation is suitable for uniprocessor and multiprocessor
systems, but works on a “least-common denominator” principle.
In particular, kernel preemption is disabled during the critical section
(which is comprised of
ufetch(9) and
ustore(9) operations), and the
multiprocessor implementation synchronizes with other CPUs using
interprocessor interrupts.
If a particular platform wishes to use the generic implementation
on uniprocessors but an optimized implementation on multiprocessors, the the
platform should define __HAVE_UCAS_MP
in
<machine/types.h>
and
provide _ucas_32_mp
() (and
_ucas_64_mp
(), if an _LP64
platform).
EFAULT
.
ucas_ptr
() would be of void
**
. The current prototype is a compromise for usability.
March 31, 2019 | NetBSD 9.2 |