From 0adba81d2efa0bcbde75f46af9ce893f4c143bc9 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Wed, 3 Dec 2014 20:45:00 +0100 Subject: [PATCH] core/thread: use disableIRQ/restoreIRQ --- core/thread.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/core/thread.c b/core/thread.c index b0422eb5bd..3d8805f98e 100644 --- a/core/thread.c +++ b/core/thread.c @@ -60,9 +60,9 @@ void thread_sleep(void) return; } - dINT(); + unsigned state = disableIRQ(); sched_set_status((tcb_t *)sched_active_thread, STATUS_SLEEPING); - eINT(); + restoreIRQ(state); thread_yield_higher(); } @@ -165,9 +165,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags, } #endif - if (!inISR()) { - dINT(); - } + unsigned state = disableIRQ(); kernel_pid_t pid = KERNEL_PID_UNDEF; for (kernel_pid_t i = KERNEL_PID_FIRST; i <= KERNEL_PID_LAST; ++i) { @@ -179,9 +177,7 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags, if (pid == KERNEL_PID_UNDEF) { DEBUG("thread_create(): too many threads!\n"); - if (!inISR()) { - eINT(); - } + restoreIRQ(state); return -EOVERFLOW; } @@ -221,19 +217,13 @@ kernel_pid_t thread_create(char *stack, int stacksize, char priority, int flags, sched_set_status(cb, STATUS_PENDING); if (!(flags & CREATE_WOUT_YIELD)) { - if (!inISR()) { - eINT(); - sched_switch(priority); - } - else { - sched_context_switch_request = 1; - } + restoreIRQ(state); + sched_switch(priority); + return pid; } } - if (!inISR() && sched_active_thread != NULL) { - eINT(); - } + restoreIRQ(state); return pid; }