diff options
author | Agustina Arzille <avarzille@riseup.net> | 2017-04-03 16:09:51 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-04-04 22:07:06 +0200 |
commit | b1730c99f882fc2662c6b64371a4b11a8231bb9f (patch) | |
tree | c4fa5fa51287aee6d6cb372f1cfa8f6413ababd6 /kern/mutex_i.h | |
parent | d5bb14cf6a8305bda2a5a73ce727e5309996a20a (diff) |
Use the new atomic operations interface
Stick to a sequentially consistent model for most atomic operations as it
matches the semantics of the existing code. Each call site will have to be
reevaluated in order to switch to more relaxed accesses where possible.
Diffstat (limited to 'kern/mutex_i.h')
-rw-r--r-- | kern/mutex_i.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/kern/mutex_i.h b/kern/mutex_i.h index 158d8f7f..69131cf8 100644 --- a/kern/mutex_i.h +++ b/kern/mutex_i.h @@ -21,8 +21,8 @@ #ifndef X15_MUTEX_PI #include <kern/assert.h> +#include <kern/atomic.h> #include <kern/mutex_types.h> -#include <machine/atomic.h> #define MUTEX_UNLOCKED 0 #define MUTEX_LOCKED 1 @@ -31,7 +31,7 @@ static inline unsigned int mutex_tryacquire(struct mutex *mutex) { - return atomic_cas_uint(&mutex->state, MUTEX_UNLOCKED, MUTEX_LOCKED); + return atomic_cas_seq_cst(&mutex->state, MUTEX_UNLOCKED, MUTEX_LOCKED); } static inline unsigned int @@ -39,7 +39,7 @@ mutex_release(struct mutex *mutex) { unsigned int state; - state = atomic_swap_uint(&mutex->state, MUTEX_UNLOCKED); + state = atomic_swap_seq_cst(&mutex->state, MUTEX_UNLOCKED); assert((state == MUTEX_LOCKED) || (state == MUTEX_CONTENDED)); return state; } |