diff options
| author | shaojinchun <[email protected]> | 2020-07-24 21:13:56 +0800 |
|---|---|---|
| committer | shaojinchun <[email protected]> | 2020-07-24 21:13:56 +0800 |
| commit | 3ed84b8d03dc9778f1c262278e2b8653de834408 (patch) | |
| tree | 7c394a561d379b58cc2b8f34e3c7b64372761ba2 /src/thread.c | |
| parent | e22bbf975e46b714b597fa0c69f06eae4cc6826e (diff) | |
解决yield操作不能及时释放cpu的问题
Diffstat (limited to 'src/thread.c')
| -rw-r--r-- | src/thread.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c index 715596b132..60aa17f381 100644 --- a/src/thread.c +++ b/src/thread.c @@ -478,7 +478,15 @@ RTM_EXPORT(rt_thread_delete); */ rt_err_t rt_thread_yield(void) { + struct rt_thread *thread; + rt_base_t lock; + + thread = rt_thread_self(); + lock = rt_hw_interrupt_disable(); + thread->remaining_tick = thread->init_tick; + thread->stat |= RT_THREAD_STAT_YIELD; rt_schedule(); + rt_hw_interrupt_enable(lock); return RT_EOK; } |
