diff options
| author | Meco Man <[email protected]> | 2022-01-08 16:30:22 -0500 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2022-01-14 22:59:19 +0800 |
| commit | 3ac9eece5a7b38ebdd90e8cd47a4e1d6fde5105d (patch) | |
| tree | 5f4837c8bb8f2713022481826c8e0fee19baa1ef /src | |
| parent | 43e7186a99c6b63541e0ff9f52c06637d1280e52 (diff) | |
[kernel] rt_thread_suspend/resume增加注释
Diffstat (limited to 'src')
| -rw-r--r-- | src/thread.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/thread.c b/src/thread.c index d1cc848777..6c221c1f29 100644 --- a/src/thread.c +++ b/src/thread.c @@ -805,7 +805,11 @@ RTM_EXPORT(rt_thread_control); /** * @brief This function will suspend the specified thread and change it to suspend state. * - * @note This function only can suspend current thread itself. + * @note This function ONLY can suspend current thread itself. + * Do not use the rt_thread_suspend and rt_thread_resume functions to synchronize the activities of threads. + * You have no way of knowing what code a thread is executing when you suspend it. + * If you suspend a thread while it is executing a critical area which is protected by a mutex, + * other threads attempt to use that mutex and have to wait. Deadlocks can occur very easily. * * @param thread is the thread to be suspended. * @@ -833,11 +837,6 @@ rt_err_t rt_thread_suspend(rt_thread_t thread) /* disable interrupt */ temp = rt_hw_interrupt_disable(); - if (stat == RT_THREAD_RUNNING) - { - /* not suspend running status thread on other core */ - RT_ASSERT(thread == rt_thread_self()); - } /* change thread stat */ rt_schedule_remove_thread(thread); @@ -857,6 +856,8 @@ RTM_EXPORT(rt_thread_suspend); /** * @brief This function will resume a thread and put it to system ready queue. * + * @note Do not use the rt_thread_suspend and rt_thread_resume functions to synchronize the activities of threads. + * * @param thread is the thread to be resumed. * * @return Return the operation status. If the return value is RT_EOK, the function is successfully executed. |
