diff options
| author | Bernard Xiong <[email protected]> | 2019-01-13 11:23:08 +0800 |
|---|---|---|
| committer | Bernard Xiong <[email protected]> | 2019-01-13 11:23:08 +0800 |
| commit | de624c52c140f9b6e6d782025398b0c0a250d666 (patch) | |
| tree | d64e7e1936215bba5e85ece456dfca31f131ccb0 /src/thread.c | |
| parent | 83b67ec3e29099bce9bdb6fc6a50becc03072d29 (diff) | |
[Kernel] Enable RUNNING status in thread.
Diffstat (limited to 'src/thread.c')
| -rw-r--r-- | src/thread.c | 14 |
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)); |
