sched/sched: Fix nxsched_suspend() logic

nxsched_deliver_task() or nxsched_merge_pending() should only be
called when a context switch is required. This behavior is
independent of whether the current task is locked.

Signed-off-by: Chengdong Wang <wangchengdong@lixiang.com>
This commit is contained in:
wangchengdong 2025-11-13 10:15:55 +08:00 committed by Xiang Xiao
parent d996c2e758
commit 2440b4ef39

View file

@ -170,13 +170,12 @@ void nxsched_suspend(FAR struct tcb_s *tcb)
{
switch_needed = nxsched_remove_readytorun(tcb);
if (switch_needed || !nxsched_islocked_tcb(rtcb))
if (switch_needed)
{
#ifdef CONFIG_SMP
switch_needed |= nxsched_deliver_task(cpu, tcb->cpu,
SWITCH_HIGHER);
nxsched_deliver_task(cpu, tcb->cpu, SWITCH_HIGHER);
#else
switch_needed |= nxsched_merge_pending();
nxsched_merge_pending();
#endif
}