Copilot commented on code in PR #20669:
URL: https://github.com/apache/nuttx/pull/20669#discussion_r4561854554


##########
sched/init/nx_start.c:
##########
@@ -151,8 +151,10 @@ dq_queue_t g_waitingforfill;
 dq_queue_t g_stoppedtasks;
 #endif
 
-/* This list of all tasks that have been initialized, but not yet
- * activated. NOTE:  This is the only list that is not prioritized.
+/* Task list for TSTATE_TASK_INACTIVE.  Initialized but not yet activated
+ * tasks are never linked into it, so it stays empty and removing such a
+ * TCB (whose links are NULL) through the generic task list helpers is a
+ * no-op.

Review Comment:
   With this PR, the generic blocked-list removal path can end up calling 
`dq_rem()` for `TSTATE_TASK_INACTIVE` TCBs that were never enqueued. That 
requires `dq_rem()` to be explicitly safe for 'unlinked node + empty list' 
inputs. If that behavior is not guaranteed by the `dq_rem()` contract, this can 
corrupt lists or crash (especially under debug assertions). Consider adding an 
explicit 'is enqueued' check in the generic remove helper (or a dedicated 
`dq_rem_if_linked()` helper), or documenting/ensuring in the queue 
implementation that removing an unlinked entry is always safe.



##########
Documentation/os/scheduling/nuttx_tasking.rst:
##########
@@ -62,14 +62,11 @@ so that common list handling logic can be used (only the 
``g_readytorun``
 and ``g_pendingtasks`` lists, and the wait lists in each semaphore, event and
 message queue, need to be prioritized).
 
-All new tasks start in an initial, non-running state:
+All new tasks start in an initial, non-running state
+(``TSTATE_TASK_INACTIVE``):
 
-.. code-block:: c
-
-  volatile dq_queue_t g_inactivetasks;
-
-* This is the list of all tasks that have been initialized, but not yet
-  activated. NOTE: This is the only list that is not prioritized.
+* Tasks that have been initialized, but not yet activated, are not kept
+  in any task list. They are only reachable through the PID hash table.

Review Comment:
   Wording is slightly ambiguous since `g_inactivetasks` still exists (it’s 
just intentionally empty). To avoid confusion, consider rephrasing to something 
like: '...are not enqueued in any task list...' and optionally mention that 
`g_inactivetasks` remains present but is not used for tracking.



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