kernel: only resume suspended threads
Do not try to resume a thread that was not suspended. Fixes #28694 Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
14b398778f
commit
bf69afcdae
2 changed files with 11 additions and 0 deletions
|
@ -105,6 +105,11 @@ static inline bool z_is_idle_thread_object(struct k_thread *thread)
|
|||
#endif /* CONFIG_MULTITHREADING */
|
||||
}
|
||||
|
||||
static inline bool z_is_thread_suspended(struct k_thread *thread)
|
||||
{
|
||||
return (thread->base.thread_state & _THREAD_SUSPENDED) != 0U;
|
||||
}
|
||||
|
||||
static inline bool z_is_thread_pending(struct k_thread *thread)
|
||||
{
|
||||
return (thread->base.thread_state & _THREAD_PENDING) != 0U;
|
||||
|
|
|
@ -487,6 +487,12 @@ void z_impl_k_thread_resume(struct k_thread *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)) {
|
||||
k_spin_unlock(&sched_spinlock, key);
|
||||
return;
|
||||
}
|
||||
|
||||
z_mark_thread_as_not_suspended(thread);
|
||||
ready_thread(thread);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue