kernel: Update k_wakeup()
This commit does two things to k_wakeup(): 1. It locks the scheduler before marking the thread as not suspended. As the the clearing of the _THREAD_SUSPENDED bit is not atomic, this helps ensure that neither another thread nor ISR interrupts this action (resulting in a corrupted thread_state). 2. The call to flag_ipi() has been removed as it is already being made within ready_thread(). Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
parent
a79c54dc43
commit
51ae993c12
1 changed files with 9 additions and 4 deletions
|
|
@ -1653,13 +1653,18 @@ void z_impl_k_wakeup(k_tid_t thread)
|
|||
}
|
||||
}
|
||||
|
||||
k_spinlock_key_t key = k_spin_lock(&sched_spinlock);
|
||||
|
||||
z_mark_thread_as_not_suspended(thread);
|
||||
z_ready_thread(thread);
|
||||
|
||||
flag_ipi();
|
||||
if (!thread_active_elsewhere(thread)) {
|
||||
ready_thread(thread);
|
||||
}
|
||||
|
||||
if (!arch_is_in_isr()) {
|
||||
z_reschedule_unlocked();
|
||||
if (arch_is_in_isr()) {
|
||||
k_spin_unlock(&sched_spinlock, key);
|
||||
} else {
|
||||
z_reschedule(&sched_spinlock, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue