kernel/sched: Fix reschedule points in SMP
There were two related bugs when in SMP mode: 1. Underneath z_reschedule(), the code was inexplicably checking the swap_ok flag on the current CPU to see if it was OK to preempt the current thread, but reschedule is the DEFINITION of a schedule point and we always want to swap, even if the current thread is non-preemptible. 2. With similar symptoms: in k_yield() a previous fix correct the queue handling for SMP, but it missed the case where a thread of the SAME priority as _current was on the queue and would fail to swap. Yielding must always add the current thread to the back of the current priority. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
dba3555ffb
commit
b0158cc81f
1 changed files with 2 additions and 5 deletions
|
@ -523,9 +523,6 @@ void z_thread_priority_set(struct k_thread *thread, int prio)
|
|||
static inline int resched(u32_t key)
|
||||
{
|
||||
#ifdef CONFIG_SMP
|
||||
if (!_current_cpu->swap_ok) {
|
||||
return 0;
|
||||
}
|
||||
_current_cpu->swap_ok = 0;
|
||||
#endif
|
||||
|
||||
|
@ -919,9 +916,9 @@ void z_impl_k_yield(void)
|
|||
z_is_thread_queued(_current)) {
|
||||
_priq_run_remove(&_kernel.ready_q.runq,
|
||||
_current);
|
||||
_priq_run_add(&_kernel.ready_q.runq,
|
||||
_current);
|
||||
}
|
||||
_priq_run_add(&_kernel.ready_q.runq, _current);
|
||||
z_mark_thread_as_queued(_current);
|
||||
update_cache(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue