From e78cfdf64b4fa6c35dfaf427599bf9d3f3cb306c Mon Sep 17 00:00:00 2001 From: Shicheng Chu <1468559561@qq.com> Date: Mon, 30 Oct 2023 23:11:40 +0800 Subject: [PATCH] =?UTF-8?q?[kernel][scheduler]Modify=20the=20timing=20of?= =?UTF-8?q?=20clearing=20RT=5FTHREAD=5FSTAT=5FYIELD=E2=80=A6=20(#8142)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scheduler_up.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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);