Skip to content
Permalink
Browse files

kernel/sched: Fix k_thread_priority_set() on SMP

On SMP systems, currently scheduled threads are not in the run queue
and can't be unconditionally removoed/added.

Fixes #17170

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
  • Loading branch information...
andyross authored and andrewboie committed Jul 1, 2019
1 parent ff7e4e6 commit 4d8e1f223bf3ba3256c50f89ce36b01d68056d76
Showing with 8 additions and 3 deletions.
  1. +8 −3 kernel/sched.c
@@ -483,9 +483,14 @@ void z_thread_priority_set(struct k_thread *thread, int prio)
need_sched = z_is_thread_ready(thread);

if (need_sched) {
_priq_run_remove(&_kernel.ready_q.runq, thread);
thread->base.prio = prio;
_priq_run_add(&_kernel.ready_q.runq, thread);
/* Don't requeue on SMP if it's the running thread */
if (!IS_ENABLED(CONFIG_SMP) || z_is_thread_queued(thread)) {
_priq_run_remove(&_kernel.ready_q.runq, thread);
thread->base.prio = prio;
_priq_run_add(&_kernel.ready_q.runq, thread);
} else {
thread->base.prio = prio;
}
update_cache(1);
} else {
thread->base.prio = prio;

0 comments on commit 4d8e1f2

Please sign in to comment.
You can’t perform that action at this time.