diff --git a/kernel/include/kthread.h b/kernel/include/kthread.h index 35049c7805bdef..a751d4cd505fae 100644 --- a/kernel/include/kthread.h +++ b/kernel/include/kthread.h @@ -108,8 +108,7 @@ static inline bool z_is_thread_timeout_active(struct k_thread *thread) static inline bool z_is_thread_ready(struct k_thread *thread) { - return !((z_is_thread_prevented_from_running(thread)) != 0U || - z_is_thread_timeout_active(thread)); + return !z_is_thread_prevented_from_running(thread); } static inline bool z_is_thread_state_set(struct k_thread *thread, uint32_t state) diff --git a/kernel/sched.c b/kernel/sched.c index 0c2be8ab74b870..add0dc51ddf106 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1164,10 +1164,10 @@ void z_impl_k_wakeup(k_tid_t thread) { SYS_PORT_TRACING_OBJ_FUNC(k_thread, wakeup, thread); - z_abort_thread_timeout(thread); - k_spinlock_key_t key = k_spin_lock(&_sched_spinlock); + z_abort_thread_timeout(thread); + if (!z_is_thread_sleeping(thread)) { k_spin_unlock(&_sched_spinlock, key); return;