diff --git a/include/kernel.h b/include/kernel.h index c0ecb882600..139496cf234 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -644,6 +644,8 @@ __syscall int k_thread_join(struct k_thread *thread, k_timeout_t timeout); * This routine puts the current thread to sleep for @a duration, * specified as a k_timeout_t object. * + * @note if @a timeout is set to K_FOREVER then the thread is suspended. + * * @param timeout Desired duration of sleep. * * @return Zero if the requested time has elapsed or the number of milliseconds diff --git a/kernel/sched.c b/kernel/sched.c index a3bd2614f71..57566a631d8 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -1310,6 +1310,7 @@ int32_t z_impl_k_sleep(k_timeout_t timeout) __ASSERT(!arch_is_in_isr(), ""); sys_trace_void(SYS_TRACE_ID_SLEEP); + /* in case of K_FOREVER, we suspend */ if (K_TIMEOUT_EQ(timeout, K_FOREVER)) { k_thread_suspend(_current); return (int32_t) K_TICKS_FOREVER;