mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-24 05:04:10 +08:00
解决yield操作不能及时释放cpu的问题
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user