kernel: Allow k_thread_abort(_current) from ISRs
Traditionally k_thread_abort() of the current thread has done a synchronous _Swap() to the new context. Doing this from an ISR has never worked portably (some architectures can do it, some can't) for this reason. But on Xtensa/asm2, exception handlers now run in interrupt context and it's a very reasonable requirement for them to abort the excepting thread. So simply don't swap, but do the rest of the bookeeping, returning to the calling context. As a side effect it's now possible to terminate threads from interrupts, even if they have been interrupted. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
0244d01fda
commit
e922df5069
1 changed files with 10 additions and 6 deletions
|
@ -37,6 +37,9 @@ void _impl_k_thread_abort(k_tid_t thread)
|
||||||
_k_thread_single_abort(thread);
|
_k_thread_single_abort(thread);
|
||||||
_thread_monitor_exit(thread);
|
_thread_monitor_exit(thread);
|
||||||
|
|
||||||
|
if (_is_in_isr()) {
|
||||||
|
irq_unlock(key);
|
||||||
|
} else {
|
||||||
if (_current == thread) {
|
if (_current == thread) {
|
||||||
_Swap(key);
|
_Swap(key);
|
||||||
CODE_UNREACHABLE;
|
CODE_UNREACHABLE;
|
||||||
|
@ -45,6 +48,7 @@ void _impl_k_thread_abort(k_tid_t thread)
|
||||||
/* The abort handler might have altered the ready queue. */
|
/* The abort handler might have altered the ready queue. */
|
||||||
_reschedule_threads(key);
|
_reschedule_threads(key);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_USERSPACE
|
#ifdef CONFIG_USERSPACE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue