summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2019-01-16 17:36:22 +0800
committerGitHub <[email protected]>2019-01-16 17:36:22 +0800
commit3b21ead135ee29596a6df7d1995e83a5613f0941 (patch)
tree04714f7864f53f87fbe263e2ec4dcbf57d469d6d /src/thread.c
parent4006129dcecea9d987d7efa3804808219ffa8803 (diff)
parentc2a85453b3452b3456d13d0a4fa4b3841a58cb17 (diff)
Merge pull request #2200 from RT-Thread/thread_stat
[Kernel] Enable RUNNING status in thread.
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/thread.c b/src/thread.c
index df9f151834..b23d2fb6b9 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -655,6 +655,7 @@ RTM_EXPORT(rt_thread_control);
*/
rt_err_t rt_thread_suspend(rt_thread_t thread)
{
+ register rt_base_t stat;
register rt_base_t temp;
/* thread check */
@@ -663,22 +664,25 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
RT_DEBUG_LOG(RT_DEBUG_THREAD, ("thread suspend: %s\n", thread->name));
- if ((thread->stat & RT_THREAD_STAT_MASK) != RT_THREAD_READY)
+ 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));
-
return -RT_ERROR;
}
- RT_ASSERT(thread == rt_thread_self());
-
/* 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 */
- thread->stat = RT_THREAD_SUSPEND | (thread->stat & ~RT_THREAD_STAT_MASK);
rt_schedule_remove_thread(thread);
+ thread->stat = RT_THREAD_SUSPEND | (thread->stat & ~RT_THREAD_STAT_MASK);
/* stop thread timer anyway */
rt_timer_stop(&(thread->thread_timer));