hujun260 commented on code in PR #19398:
URL: https://github.com/apache/nuttx/pull/19398#discussion_r3563452077
##########
sched/task/task_exit.c:
##########
@@ -77,14 +77,18 @@ int nxtask_exit(void)
FAR struct tcb_s *dtcb;
FAR struct tcb_s *rtcb;
int ret;
-#ifdef CONFIG_SMP
/* Avoid using this_task() because it may assume a state that is not
- * appropriate for an exiting task.
+ * appropriate for an exiting task: if a higher-priority task became
+ * ready and was placed at the head of the ready-to-run list while
+ * the context switch away from the exiting task is still deferred,
+ * this_task() (the ready-to-run head) no longer identifies the task
+ * that is actually exiting.
*/
+#ifdef CONFIG_SMP
dtcb = current_task(this_cpu());
#else
- dtcb = this_task();
+ dtcb = g_running_tasks[this_cpu()];
Review Comment:
I noticed you replaced this_task() with g_running_tasks[this_cpu()]. Could
you explain under what circumstances these two might not be equal in
nxtask_exit?
--
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]