diff options
author | Richard Braun <rbraun@sceen.net> | 2017-09-02 16:06:54 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-09-02 16:06:54 +0200 |
commit | 7ded1b60d46d8582be0d86cd7176048bcfe30ccf (patch) | |
tree | 3b1ed96ad276c6aeff56c58380e59e643559e9c4 /kern/thread.h | |
parent | 1469ce26e2e58082fd4bbb343cad60f2d696a641 (diff) |
kern/thread: new preemption control macros
These new macros take care of disabling/restoring interrupts in the
appropriate order.
Diffstat (limited to 'kern/thread.h')
-rw-r--r-- | kern/thread.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/kern/thread.h b/kern/thread.h index 1a811685..07973431 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -570,6 +570,17 @@ thread_preempt_enabled(void) } static inline void +thread_preempt_disable(void) +{ + struct thread *thread; + + thread = thread_self(); + thread->preempt++; + assert(thread->preempt != 0); + barrier(); +} + +static inline void thread_preempt_enable_no_resched(void) { struct thread *thread; @@ -600,14 +611,17 @@ thread_preempt_enable(void) } static inline void -thread_preempt_disable(void) +thread_preempt_disable_intr_save(unsigned long *flags) { - struct thread *thread; + thread_preempt_disable(); + cpu_intr_save(flags); +} - thread = thread_self(); - thread->preempt++; - assert(thread->preempt != 0); - barrier(); +static inline void +thread_preempt_enable_intr_restore(unsigned long flags) +{ + cpu_intr_restore(flags); + thread_preempt_enable(); } /* |