pkarashchenko commented on code in PR #7599:
URL: https://github.com/apache/incubator-nuttx/pull/7599#discussion_r1027104724


##########
arch/arm64/src/common/arm64_unblocktask.c:
##########
@@ -43,102 +43,70 @@
  * Name: up_unblock_task
  *
  * Description:
- *   A task is currently in an inactive task list
- *   but has been prepped to execute.  Move the TCB to the
- *   ready-to-run list, restore its context, and start execution.
+ *   A task is currently in the ready-to-run list but has been prepped
+ *   to execute. Restore its context, and start execution.
  *
  * Input Parameters:
- *   tcb: Refers to the tcb to be unblocked.  This tcb is
- *     in one of the waiting tasks lists.  It must be moved to
- *     the ready-to-run list and, if it is the highest priority
- *     ready to run task, executed.
+ *   tcb: Refers to the head task of the ready-to-run list
+ *     which will be executed.
+ *   rtcb: Refers to the running task which will be blocked.
  *
  ****************************************************************************/
 
-void up_unblock_task(struct tcb_s *tcb)
+void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
 {
-  struct tcb_s *rtcb = this_task();
+  /* Update scheduler parameters */
 
-  /* Verify that the context switch can be performed */
+  nxsched_suspend_scheduler(rtcb);
 
-  DEBUGASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) &&
-              (tcb->task_state <= LAST_BLOCKED_STATE));
+  /* Are we in an interrupt handler? */
 
-  /* Remove the task from the blocked task list */
-
-  nxsched_remove_blocked(tcb);
-
-  /* Add the task in the correct location in the prioritized
-   * ready-to-run task list
-   */
-
-  if (nxsched_add_readytorun(tcb))
+  if (CURRENT_REGS)
     {
-      /* The currently active task has changed! We need to do
-       * a context switch to the new task.
+      /* Yes, then we have to do things differently.
+       * Just copy the CURRENT_REGS into the OLD rtcb.
        */
 
-      /* Update scheduler parameters */
-
-      nxsched_suspend_scheduler(rtcb);
-
-      /* Are we in an interrupt handler? */
-
-      if (CURRENT_REGS)
-        {
-          /* Yes, then we have to do things differently.
-           * Just copy the CURRENT_REGS into the OLD rtcb.
-           */
-
-          arm64_savestate(rtcb->xcp.regs);
-
-          /* Restore the exception context of the rtcb at the (new) head
-           * of the ready-to-run task list.
-           */
-
-          rtcb = this_task();
+      arm64_savestate(rtcb->xcp.regs);
 
-          /* Update scheduler parameters */
-
-          nxsched_resume_scheduler(rtcb);
+      /* Update scheduler parameters */
 
-          /* Then switch contexts.  Any necessary address environment
-           * changes will be made when the interrupt returns.
-           */
+      nxsched_resume_scheduler(tcb);
 
-          arm64_restorestate(rtcb->xcp.regs);
-        }
+      /* Then switch contexts.  Any necessary address environment
+       * changes will be made when the interrupt returns.
+       */
 
-      /* No, then we will need to perform the user context switch */
+      arm64_restorestate(tcb->xcp.regs);
+    }
 
-      else
-        {
-          struct tcb_s *nexttcb = this_task();
+  /* No, then we will need to perform the user context switch */
 
+  else
+    {
 #ifdef CONFIG_ARCH_ADDRENV
-          /* Make sure that the address environment for the previously
-           * running task is closed down gracefully (data caches dump,
-           * MMU flushed) and set up the address environment for the new
-           * thread at the head of the ready-to-run list.
-           */
+      /* Make sure that the address environment for the previously
+       * running task is closed down gracefully (data caches dump,
+       * MMU flushed) and set up the address environment for the new
+       * thread at the head of the ready-to-run list.
+       */
 
-          group_addrenv(nexttcb);
+      group_addrenv(tcb);

Review Comment:
   But ARM64 also have it at the exactly same place in `arm64_doirq`. So why 
calling in unblocktask is also needed?



-- 
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