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/thread_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/thread_i.h')
-rw-r--r-- | kern/thread_i.h | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/kern/thread_i.h b/kern/thread_i.h index b0e0074f..34761e56 100644 --- a/kern/thread_i.h +++ b/kern/thread_i.h @@ -20,6 +20,7 @@ #include <stdbool.h> +#include <kern/atomic.h> #include <kern/condition_types.h> #include <kern/cpumap.h> #include <kern/list_types.h> @@ -27,7 +28,6 @@ #include <kern/mutex_types.h> #include <kern/param.h> #include <kern/turnstile_types.h> -#include <machine/atomic.h> #include <machine/tcb.h> /* @@ -195,20 +195,19 @@ void thread_destroy(struct thread *thread); static inline void thread_set_flag(struct thread *thread, unsigned long flag) { - atomic_or_ulong(&thread->flags, flag); + atomic_or(&thread->flags, flag, ATOMIC_SEQ_CST); } static inline void thread_clear_flag(struct thread *thread, unsigned long flag) { - atomic_and_ulong(&thread->flags, ~flag); + atomic_and(&thread->flags, ~flag, ATOMIC_SEQ_CST); } static inline int thread_test_flag(struct thread *thread, unsigned long flag) { - barrier(); - return ((thread->flags & flag) != 0); + return (atomic_load(&thread->flags, ATOMIC_ACQUIRE) & flag) != 0; } #endif /* _KERN_THREAD_I_H */ |