diff --git a/kernel/pipes.c b/kernel/pipes.c index 857005d1e9a..0c108c3c834 100644 --- a/kernel/pipes.c +++ b/kernel/pipes.c @@ -349,9 +349,10 @@ static size_t pipe_write(struct k_pipe *pipe, sys_dlist_t *src_list, } } else if (dest->bytes_to_xfer == 0U) { - /* A thread's read request has been satisfied. */ + /* The thread's read request has been satisfied. */ - (void) z_sched_wake(&pipe->wait_q.readers, 0, NULL); + z_unpend_thread(dest->thread); + z_ready_thread(dest->thread); *reschedule = true; } @@ -586,7 +587,8 @@ static int pipe_get_internal(k_spinlock_key_t key, struct k_pipe *pipe, /* The thread's write request has been satisfied. */ - (void) z_sched_wake(&pipe->wait_q.writers, 0, NULL); + z_unpend_thread(src_desc->thread); + z_ready_thread(src_desc->thread); reschedule_needed = true; } diff --git a/kernel/sched.c b/kernel/sched.c index 3cc81dab46a..b9c326c494d 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -788,7 +788,9 @@ static inline void unpend_thread_no_timeout(struct k_thread *thread) ALWAYS_INLINE void z_unpend_thread_no_timeout(struct k_thread *thread) { LOCKED(&sched_spinlock) { - unpend_thread_no_timeout(thread); + if (thread->base.pended_on != NULL) { + unpend_thread_no_timeout(thread); + } } }