diff --git a/cpu/native/irq_cpu.c b/cpu/native/irq_cpu.c index ae16a0c5e7..1558d5429d 100644 --- a/cpu/native/irq_cpu.c +++ b/cpu/native/irq_cpu.c @@ -201,6 +201,11 @@ unsigned irq_enable(void) _native_syscall_leave(); + if (_native_in_isr == 0 && sched_context_switch_request) { + DEBUG("irq_enable() deferred thread_yield_higher()\n"); + thread_yield_higher(); + } + DEBUG("irq_enable(): return\n"); return prev_state; diff --git a/cpu/native/native_cpu.c b/cpu/native/native_cpu.c index 136908bd6b..5fb6241628 100644 --- a/cpu/native/native_cpu.c +++ b/cpu/native/native_cpu.c @@ -210,12 +210,9 @@ void thread_yield_higher(void) { sched_context_switch_request = 1; - if (_native_in_isr == 0) { + if (_native_in_isr == 0 && native_interrupts_enabled) { ucontext_t *ctx = (ucontext_t *)(thread_get_active()->sp); _native_in_isr = 1; - if (!native_interrupts_enabled) { - warnx("thread_yield_higher: interrupts are disabled - this should not be"); - } irq_disable(); native_isr_context.uc_stack.ss_sp = __isr_stack; native_isr_context.uc_stack.ss_size = SIGSTKSZ;