kernel/sched: _thread_priority_set needs to be sched_lock aware

This API doesn't use the normal thread priority comparison itself, so
doesn't get the magic that thread_base.prio provides.  If called when
another thread should be run, this would preempt the current thread
always, even if the scheduler lock was taken.

That was benign until recent spinlockifiation exposed it: a mutex in
the philosophers test run in preempt_only mode would swap away while
holding a spinlock (which used to work with irq locks) and fail later
with a "recursive" spinlock assert.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2019-02-06 17:27:14 -08:00 committed by Anas Nashif
parent d653e6868e
commit 1202810119

View file

@ -489,7 +489,7 @@ void _thread_priority_set(struct k_thread *thread, int prio)
}
sys_trace_thread_priority_set(thread);
if (need_sched) {
if (need_sched && _current->base.sched_locked == 0) {
_reschedule_unlocked();
}
}