From f1ba7c65ad6041fb6d6925820c7a088d9bdf86a4 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Fri, 24 Dec 2021 16:06:47 -0500 Subject: [PATCH] =?UTF-8?q?[kernel]=20rt=5Fthread=5Fsuspend=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/thread.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/thread.c b/src/thread.c index 7913e12f5d..d1eb2d01e5 100644 --- a/src/thread.c +++ b/src/thread.c @@ -760,8 +760,7 @@ RTM_EXPORT(rt_thread_control); /** * @brief This function will suspend the specified thread and change it to suspend state. * - * @note If suspend self thread, after this function call, the - * rt_schedule() must be invoked. + * @note This function only can suspend current thread itself. * * @param thread is the thread to be suspended. * @@ -776,14 +775,14 @@ rt_err_t rt_thread_suspend(rt_thread_t thread) /* thread check */ RT_ASSERT(thread != RT_NULL); RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread); + RT_ASSERT(thread == rt_thread_self()); RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->name)); stat = thread->stat & RT_THREAD_STAT_MASK; if ((stat != RT_THREAD_READY) && (stat != RT_THREAD_RUNNING)) { - RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, 0x%2x\n", - thread->stat)); + RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, 0x%2x\n", thread->stat)); return -RT_ERROR; }