diff --git a/kernel/mailbox.c b/kernel/mailbox.c index e355d724b7..1c5bb95659 100644 --- a/kernel/mailbox.c +++ b/kernel/mailbox.c @@ -285,8 +285,7 @@ static int mbox_message_put(struct k_mbox *mbox, struct k_mbox_msg *tx_msg, * synchronous send: pend current thread (unqueued) * until the receiver consumes the message */ - _remove_thread_from_ready_q(_current); - _mark_thread_as_pending(_current); + _pend_current_thread(NULL, K_FOREVER); return _Swap(key); } } diff --git a/kernel/sched.c b/kernel/sched.c index e7d6ec2586..34f16c2903 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -203,6 +203,10 @@ void _pend_thread(struct k_thread *thread, _wait_q_t *wait_q, s32_t timeout) sys_dlist_t *wait_q_list = (sys_dlist_t *)wait_q; struct k_thread *pending; + if (!wait_q_list) { + goto inserted; + } + SYS_DLIST_FOR_EACH_CONTAINER(wait_q_list, pending, base.k_q_node) { if (_is_t1_higher_prio_than_t2(thread, pending)) { sys_dlist_insert_before(wait_q_list,