diff --git a/src/scheduler_up.c b/src/scheduler_up.c index d8b13a5620..34193b0acc 100644 --- a/src/scheduler_up.c +++ b/src/scheduler_up.c @@ -29,6 +29,7 @@ * new task directly * 2022-01-07 Gabriel Moving __on_rt_xxxxx_hook to scheduler.c * 2023-03-27 rose_man Split into scheduler upc and scheduler_mp.c + * 2023-10-17 ChuShicheng Modify the timing of clearing RT_THREAD_STAT_YIELD flag bits */ #include @@ -270,7 +271,6 @@ void rt_schedule(void) { need_insert_from_thread = 1; } - rt_current_thread->stat &= ~RT_THREAD_STAT_YIELD_MASK; } if (to_thread != rt_current_thread) @@ -287,6 +287,11 @@ void rt_schedule(void) rt_schedule_insert_thread(from_thread); } + if ((from_thread->stat & RT_THREAD_STAT_YIELD_MASK) != 0) + { + from_thread->stat &= ~RT_THREAD_STAT_YIELD_MASK; + } + rt_schedule_remove_thread(to_thread); to_thread->stat = RT_THREAD_RUNNING | (to_thread->stat & ~RT_THREAD_STAT_MASK);