This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 0c6fe04ef73 Revert "sched_idletask: remove the check for whether tcb
is NULL"
0c6fe04ef73 is described below
commit 0c6fe04ef736296bdbe85296dc76c8b5a64c39b9
Author: hujun5 <[email protected]>
AuthorDate: Thu Nov 27 15:44:16 2025 +0800
Revert "sched_idletask: remove the check for whether tcb is NULL"
This reverts commit 8f91054b1d3f88d528c5327340de41d4f63c4262.
Signed-off-by: hujun5 <[email protected]>
---
sched/sched/sched_idletask.c | 34 ++++++++++++++++++++++------------
1 file changed, 22 insertions(+), 12 deletions(-)
diff --git a/sched/sched/sched_idletask.c b/sched/sched/sched_idletask.c
index 1c428c69025..dacaa19ff2a 100644
--- a/sched/sched/sched_idletask.c
+++ b/sched/sched/sched_idletask.c
@@ -60,18 +60,28 @@ bool sched_idletask(void)
{
FAR struct tcb_s *rtcb = this_task();
- DEBUGASSERT(rtcb);
-
- /* The IDLE task TCB is distinguishable by a few things:
- *
- * (1) It always lies at the end of the task list,
- * (2) It always has priority zero, and
- * (3) It should have the TCB_FLAG_CPU_LOCKED flag set.
- *
- * In the non-SMP case, the IDLE task will also have PID=0, but that
- * is not a portable test because there are multiple IDLE tasks with
- * different PIDs in the SMP configuration.
+ /* If called early in the initialization sequence, the tasks lists may not
+ * have been initialized and, in that case, rtcb may be NULL.
*/
- return is_idle_task(rtcb);
+ DEBUGASSERT(rtcb != NULL || !OSINIT_TASK_READY());
+ if (rtcb != NULL)
+ {
+ /* The IDLE task TCB is distinguishable by a few things:
+ *
+ * (1) It always lies at the end of the task list,
+ * (2) It always has priority zero, and
+ * (3) It should have the TCB_FLAG_CPU_LOCKED flag set.
+ *
+ * In the non-SMP case, the IDLE task will also have PID=0, but that
+ * is not a portable test because there are multiple IDLE tasks with
+ * different PIDs in the SMP configuration.
+ */
+
+ return is_idle_task(rtcb);
+ }
+
+ /* We must be on the IDLE thread if we are early in initialization */
+
+ return true;
}