From eb9f8074c0dd9b05be0501ef1d24d85c7740c2bb Mon Sep 17 00:00:00 2001
From: Gregory Nutt <gnutt@nuttx.org>
Date: Thu, 24 Nov 2016 09:56:12 -0600
Subject: [PATCH] Update comments

---
 sched/sched/sched_mergepending.c     |  4 ++--
 sched/sched/sched_removereadytorun.c | 16 +++++++++++-----
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/sched/sched/sched_mergepending.c b/sched/sched/sched_mergepending.c
index 07a554ff06..863eb73c27 100644
--- a/sched/sched/sched_mergepending.c
+++ b/sched/sched/sched_mergepending.c
@@ -271,11 +271,11 @@ bool sched_mergepending(void)
               return ret;
             }
 
-          cpu = sched_cpu_select(ALL_CPUS /* ptcb->affinity */);
+          cpu  = sched_cpu_select(ALL_CPUS /* ptcb->affinity */);
           rtcb = current_task(cpu);
         }
 
-      /* No more pending tasks can be made running.  Move any reamaining
+      /* No more pending tasks can be made running.  Move any remaining
        * tasks in the pending task list to the ready-to-run task list.
        */
 
diff --git a/sched/sched/sched_removereadytorun.c b/sched/sched/sched_removereadytorun.c
index 85c3d43fac..5b6b663d97 100644
--- a/sched/sched/sched_removereadytorun.c
+++ b/sched/sched/sched_removereadytorun.c
@@ -145,7 +145,7 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb)
   cpu      = rtcb->cpu;
   tasklist = TLIST_HEAD(rtcb->task_state, cpu);
 
-  /* Check if the TCB to be removed is at the head of a ready to run list.
+  /* Check if the TCB to be removed is at the head of a ready-to-run list.
    * For the case of SMP, there are two lists involved:  (1) the
    * g_readytorun list that holds non-running tasks that have not been
    * assigned to a CPU, and (2) and the g_assignedtasks[] lists which hold
@@ -154,9 +154,12 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb)
    * only only removing the head of that list can result in a context
    * switch.
    *
-   * The tasklist RUNNABLE attribute will inform us if the list holds the
-   * currently executing and task and, hence, if a context switch could
-   * occur.
+   * rtcb->blink == NULL will tell us if the TCB is at the head of the
+   * ready-to-run list and, hence, a candidate for the new running task.
+   *
+   * If so, then the tasklist RUNNABLE attribute will inform us if the list
+   * holds the currently executing task and, hence, if a context switch
+   * should occur.
    */
 
   if (rtcb->blink == NULL && TLIST_ISRUNNABLE(rtcb->task_state))
@@ -205,7 +208,10 @@ bool sched_removereadytorun(FAR struct tcb_s *rtcb)
            rtrtcb = (FAR struct tcb_s *)rtrtcb->flink);
 
       /* Did we find a task in the g_readytorun list?  Which task should
-       * we use? We decide strictly by the priority of the two tasks.
+       * we use?  We decide strictly by the priority of the two tasks:
+       * Either (1) the task currently at the head of the g_assignedtasks[cpu]
+       * list (nexttcb) or (2) the highest priority task from the
+       * g_readytorun list with matching affinity (rtrtcb).
        */
 
       if (rtrtcb != NULL && rtrtcb->sched_priority >= nxttcb->sched_priority)