kernel/sched: Handle aboring _current correctly in SMP

In SMP, _current is not "queued".  (The run queue only stores
unscheduled threads because we can't rely on the head of the list
being _current).  We weren't updating the cache choice, which would
flag swap_ok, so calling k_thread_abort(_current) (for example, when a
thread exits from its entry function) would try to switch back into
the thread and then run off the end of the function.

Amusingly this was more benign than you'd think.  Stumbled on it by
accident.

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
Andy Ross 2019-02-14 18:30:32 -08:00 committed by Anas Nashif
commit aed8288196

View file

@ -353,8 +353,8 @@ void z_remove_thread_from_ready_q(struct k_thread *thread)
if (z_is_thread_queued(thread)) {
_priq_run_remove(&_kernel.ready_q.runq, thread);
z_mark_thread_as_not_queued(thread);
update_cache(thread == _current);
}
update_cache(thread == _current);
}
}