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:
parent
ff7e4e69c8
commit
4d8e1f223b
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue