From 1621fcb09e15d76e09331bff73b096ac5c45828b Mon Sep 17 00:00:00 2001 From: chenhonglin Date: Fri, 24 Sep 2021 10:19:02 +0800 Subject: [PATCH] sched/sched/remove_readytorun.c: Fix CPU affinity issues in SMP THOR-208 In "nxsched_remove_readytorun": the logical may choose the head of g_readytorun(the greatest priority) task as the next while ignoring the cpu affinity of it. Signed-off-by: chenhonglin Change-Id: I819dd6f3fc0feff4e378cfda2a6c581814065cb3 --- sched/sched/sched_removereadytorun.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sched/sched/sched_removereadytorun.c b/sched/sched/sched_removereadytorun.c index 170e18b8356..f1a84a9fd6d 100644 --- a/sched/sched/sched_removereadytorun.c +++ b/sched/sched/sched_removereadytorun.c @@ -209,20 +209,16 @@ bool nxsched_remove_readytorun(FAR struct tcb_s *rtcb) if (rtrtcb != NULL && rtrtcb->sched_priority >= nxttcb->sched_priority) { - FAR struct tcb_s *tmptcb; - /* The TCB at the head of the ready to run list has the higher * priority. Remove that task from the head of the g_readytorun * list and add to the head of the g_assignedtasks[cpu] list. */ - tmptcb = (FAR struct tcb_s *) - dq_remfirst((FAR dq_queue_t *)&g_readytorun); + dq_rem((FAR dq_entry_t *)rtrtcb, (FAR dq_queue_t *)&g_readytorun); + dq_addfirst((FAR dq_entry_t *)rtrtcb, tasklist); - dq_addfirst((FAR dq_entry_t *)tmptcb, tasklist); - - tmptcb->cpu = cpu; - nxttcb = tmptcb; + rtrtcb->cpu = cpu; + nxttcb = rtrtcb; } /* Will pre-emption be disabled after the switch? If the lockcount is