Browse Source

kernel: Fix k_wakeup() exit paths

z_reschedule() already has a check to determine if it is called from
the context of an ISR--no need to duplicate it in k_wakeup().
Furthermore, if the target thread is not sleeping, there is no need
to reschedule and we can do a fast return.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
pull/85097/head
Peter Mitsis 7 months ago committed by Benjamin Cabé
parent
commit
c63b42d478
  1. 20
      kernel/sched.c

20
kernel/sched.c

@ -1164,21 +1164,13 @@ void z_impl_k_wakeup(k_tid_t thread) @@ -1164,21 +1164,13 @@ void z_impl_k_wakeup(k_tid_t 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;
}
z_mark_thread_as_not_sleeping(thread);
ready_thread(thread);
if (arch_is_in_isr()) {
k_spin_unlock(&_sched_spinlock, key);
} else {
if (z_is_thread_sleeping(thread)) {
z_abort_thread_timeout(thread);
z_mark_thread_as_not_sleeping(thread);
ready_thread(thread);
z_reschedule(&_sched_spinlock, key);
} else {
k_spin_unlock(&_sched_spinlock, key);
}
}

Loading…
Cancel
Save