diff --git a/kernel/thread_abort.c b/kernel/thread_abort.c index fe54cda4f2c..be6485e46fa 100644 --- a/kernel/thread_abort.c +++ b/kernel/thread_abort.c @@ -37,13 +37,17 @@ void _impl_k_thread_abort(k_tid_t thread) _k_thread_single_abort(thread); _thread_monitor_exit(thread); - if (_current == thread) { - _Swap(key); - CODE_UNREACHABLE; - } + if (_is_in_isr()) { + irq_unlock(key); + } else { + if (_current == thread) { + _Swap(key); + CODE_UNREACHABLE; + } - /* The abort handler might have altered the ready queue. */ - _reschedule_threads(key); + /* The abort handler might have altered the ready queue. */ + _reschedule_threads(key); + } } #endif