kernel: thread suspend/resume bail paths are unlikely

Gives a hint to the compiler that the bail-out paths in both
k_thread_suspend() and k_thread_resume() are unlikely events.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2024-11-09 12:01:37 -08:00 committed by Benjamin Cabé
commit d774594547

View file

@ -465,7 +465,7 @@ void z_impl_k_thread_suspend(k_tid_t thread)
k_spinlock_key_t key = k_spin_lock(&_sched_spinlock);
if ((thread->base.thread_state & _THREAD_SUSPENDED) != 0U) {
if (unlikely(z_is_thread_suspended(thread))) {
/* The target thread is already suspended. Nothing to do. */
@ -494,7 +494,7 @@ void z_impl_k_thread_resume(k_tid_t thread)
k_spinlock_key_t key = k_spin_lock(&_sched_spinlock);
/* Do not try to resume a thread that was not suspended */
if (!z_is_thread_suspended(thread)) {
if (unlikely(!z_is_thread_suspended(thread))) {
k_spin_unlock(&_sched_spinlock, key);
return;
}