patacongo commented on code in PR #11226:
URL: https://github.com/apache/nuttx/pull/11226#discussion_r1399759336


##########
sched/sched/sched_removereadytorun.c:
##########
@@ -194,22 +194,15 @@ bool nxsched_remove_readytorun(FAR struct tcb_s *rtcb, 
bool merge)
        * next tcb in the assigned task list (nxttcb) or a TCB in the
        * g_readytorun list.  We can only select a task from that list if
        * the affinity mask includes the current CPU.
-       *
-       * If pre-emption is locked or another CPU is in a critical section,
-       * then use the 'nxttcb' which will probably be the IDLE thread.
-       * REVISIT: What if it is not the IDLE thread?
        */

Review Comment:
   I am trying to understand why the IDLE thread is running after this change 
in your test example.  I may need more explanation.
   
   The IDLE thread will be the one at the end of the list of assigned threads.  
Normally there are only two tasks in the assigned task list:  The current 
running task and the IDLE thread.
   
   It looks like if a thread has been "assigned" to the CPU via one of the 
setaffinity() functions, the TCB is now retwined in the ready-to-run list.
   
   This loop has nothing to do with the IDLE thread:
   
          for (rtrtcb = (FAR struct tcb_s *)g_readytorun.head;
                rtrtcb != NULL && !CPU_ISSET(cpu, &rtrtcb->affinity) ;
                rtrtcb = rtrtcb->flink);
   
   Each CPU has its own assigned IDLE tread and that lies at the tail of the 
assigned task list.  The above loop searches ready-to-run list to find the 
first (i.e., highest priority) thread that is ready to run.  It ignores threads 
that are assigned to different CPUs.
   
   The TCB is not removed
   
   * If no thread is ready to run or if the thread has pre-emption locked (then 
rtrtcb will be NULL)
   * The thread that is found has lower priority than the thread that is 
currently running.
   
   After much puzzling, I think this is correct.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to