From 1df0b5644ab4a00b3a4e982b05de91d9b28c28a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Tue, 23 Sep 2014 07:11:35 +0200 Subject: [PATCH] core: sched_switch only switch for higher priority sched_switch() is called by some library functions when a call unblocks another thread. Then it needs to be tested if the current thread should be preempted for the newly runnable thread. A non-volutarily yield should only happen if the unblocked thread has a _higher_ priority than the current thread. The current implementation, which tests if the other thread has the same or a higher priority, does not fit the documentation. --- core/sched.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/sched.c b/core/sched.c index 13a43a63d5..2b92335b62 100644 --- a/core/sched.c +++ b/core/sched.c @@ -158,7 +158,7 @@ void sched_switch(uint16_t other_prio) DEBUG("%s: %" PRIu16 " %" PRIu16 " %i\n", sched_active_thread->name, current_prio, other_prio, in_isr); - if (current_prio >= other_prio) { + if (current_prio > other_prio) { if (in_isr) { sched_context_switch_request = 1; }