summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorMeco Man <[email protected]>2021-12-24 16:06:47 -0500
committerBernard Xiong <[email protected]>2021-12-30 01:27:54 +0800
commitf1ba7c65ad6041fb6d6925820c7a088d9bdf86a4 (patch)
tree41043d7c2073d9018c11faef881f89eaa36c05b3 /src/thread.c
parent85276f453578e0ea74f39cfcc609f867f919f059 (diff)
[kernel] rt_thread_suspend增加断言
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c7
1 files 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;
}