Browse Source

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>
pull/83254/head
Peter Mitsis 8 months ago committed by Benjamin Cabé
parent
commit
d774594547
  1. 4
      kernel/sched.c

4
kernel/sched.c

@ -465,7 +465,7 @@ void z_impl_k_thread_suspend(k_tid_t thread)
k_spinlock_key_t key = k_spin_lock(&_sched_spinlock); 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. */ /* 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); k_spinlock_key_t key = k_spin_lock(&_sched_spinlock);
/* Do not try to resume a thread that was not suspended */ /* 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); k_spin_unlock(&_sched_spinlock, key);
return; return;
} }

Loading…
Cancel
Save