Skip to content

Commit f1ba7c6

Browse files
mysterywolfBernardXiong
authored andcommitted
[kernel] rt_thread_suspend增加断言
1 parent 85276f4 commit f1ba7c6

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/thread.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,7 @@ RTM_EXPORT(rt_thread_control);
760760
/**
761761
* @brief This function will suspend the specified thread and change it to suspend state.
762762
*
763-
* @note If suspend self thread, after this function call, the
764-
* rt_schedule() must be invoked.
763+
* @note This function only can suspend current thread itself.
765764
*
766765
* @param thread is the thread to be suspended.
767766
*
@@ -776,14 +775,14 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
776775
/* thread check */
777776
RT_ASSERT(thread != RT_NULL);
778777
RT_ASSERT(rt_object_get_type((rt_object_t)thread) == RT_Object_Class_Thread);
778+
RT_ASSERT(thread == rt_thread_self());
779779

780780
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->name));
781781

782782
stat = thread->stat & RT_THREAD_STAT_MASK;
783783
if ((stat != RT_THREAD_READY) && (stat != RT_THREAD_RUNNING))
784784
{
785-
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, 0x%2x\n",
786-
thread->stat));
785+
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: thread disorder, 0x%2x\n", thread->stat));
787786
return -RT_ERROR;
788787
}
789788

0 commit comments

Comments
 (0)