jlaitine commented on code in PR #16673:
URL: https://github.com/apache/nuttx/pull/16673#discussion_r2281346216


##########
sched/sched/sched_unlock.c:
##########
@@ -81,18 +83,22 @@ void sched_unlock(void)
           sched_note_preemption(rtcb, false);
 
           /* Release any ready-to-run tasks that have collected in
-           * g_pendingtasks.
+           * g_pendingtasks (or in g_readytorun for SMP)
            *
            * NOTE: This operation has a very high likelihood of causing
            * this task to be switched out!
            */
 
-          if (list_pendingtasks()->head != NULL)
+#ifdef CONFIG_SMP
+          ptcb = (FAR struct tcb_s *)dq_peek(list_readytorun());
+          if (ptcb && ptcb->sched_priority > rtcb->sched_priority &&
+              nxsched_deliver_task(rtcb->cpu, rtcb->cpu, SWITCH_HIGHER))

Review Comment:
   No, ptcb is not running, so it is not assigned to any CPU. Iow, the 
ptcb->cpu is not valid. This code says "deliver task by this CPU to this CPU". 
In other words, just try to switch the currently running task on this CPU. The 
"nxsched_deliver_task" will then check if the switch on this CPU is not already 
pending and call the nxsched_switch_running. Which will do the rest of the 
checks like affinity, lockings etc. and actually select the next one (or leave 
the current one running).
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to