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>
This commit is contained in:
Andy Ross 2019-07-01 10:25:55 -07:00 committed by Andrew Boie
parent ff7e4e69c8
commit 4d8e1f223b

View file

@ -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;