You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "jingfei195887 (via GitHub)" <gi...@apache.org> on 2026/10/14 15:18:38 UTC

[PR] sched/task: stop linking new tasks into the inactive list [nuttx]

jingfei195887 opened a new pull request, #20669:
URL: https://github.com/apache/nuttx/pull/20669

   ## Summary
   
   Related to the footprint discussion in #20414.
   
   Tasks between setup and activation are added to `g_inactivetasks` and removed
   again on activation or teardown, but nothing walks that list: tasks are found
   through `g_pidhash`. The extra critical section and list operations add code to
   every task creation path (`nxtask_init`, fork, restart, and their error paths).
   
   This change stops linking such tasks into the list. `TSTATE_TASK_INACTIVE`
   and its (now always empty) list entry in `g_tasklisttable` are kept, so the
   generic blocked-list helpers keep working unchanged:
   
   - `nxtask_activate()` and `nxsched_suspend()` remove the TCB through
     `nxsched_remove_blocked()` -> `dq_rem()`. A TCB entering the inactive state
     always has NULL `flink`/`blink`: new TCBs come from `kmm_zalloc()`, and
     `nxtask_restart()` unlinks the TCB with `dq_rem()` (which clears both links)
     before resetting it. `dq_rem()` of such a node from an empty list leaves the
     list empty and the node unchanged.
   - Nothing else iterates the list or depends on its contents.
   
   The tasking documentation is updated to match.
   
   ## Impact
   
   - No functional change. No API or ABI change.
   - Removes one critical section and the list insert/remove from each task
     creation and teardown path.
   
   ## Testing
   
   Host: Ubuntu x86_64, arm-none-eabi-gcc 10.3.1 20210621, master be9dc4cbaa,
   clean CMake builds.
   
   | build | master | this PR | delta |
   |---|---:|---:|---:|
   | `stm32f103-minimum:nsh` flash (text + data) | 52443 | 52371 | **-72** |
   
   Runtime, with `DEBUG_FEATURES=y` and `DEBUG_ASSERTIONS=y`:
   - `sim:ostest`, patched and master side by side: both reached `timedwait_test`
     within a 400 s timeout, ran the same tests in the same order, and the
     `task_restart` test completed (`restart_main: Exiting` twice) in both.
     No assertion, panic or `ERROR`. ostest did not finish within the timeout in
     either build, so this shows no difference rather than a full pass.
   - `sim:smp`: boots to `nsh>`, `hello` runs, ostest starts and passes the
     `task_restart` test with no assertion.
   
   Other checks:
   - `sim:smp` (default config) builds.
   - `./tools/checkpatch.sh -g master..HEAD`: all checks pass.
   
   Not tested on hardware.
   


-- 
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-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] sched/task: stop linking new tasks into the inactive list [nuttx]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20669:
URL: https://github.com/apache/nuttx/pull/20669#issuecomment-6175322136

   <!-- membrowse-pr-comment -->
   ## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
   
   ### [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **flash**: .text -136 B (-0.2%, 65,800 B / 262,144 B, total: 25% used)
   ### [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **ROM**: .flash.text -72 B (-0.1%, 125,848 B / 4,194,272 B, total: 3% used)
     - **irom0_0_seg**: .flash.text -72 B (-0.1%, 90,052 B / 3,342,304 B, total: 3% used)
   ### [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **kseg0_progmem**: .text -120 B (-0.2%, 67,816 B / 131,072 B, total: 52% used)
   ### [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **Code**: .text.nxtask_uninit -48 B, .text.nxthread_setup_scheduler -48 B, .text.task_restart -36 B (-0.0%, 347,980 B)
   ### [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **Code**: .text -180 B (-0.0%, 8,682,975 B)
   ### [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **ROM**: .text -32 B (-0.0%, 87,236 B / 2,097,152 B, total: 4% used)
   ### [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **Code**: .text -320 B (-0.1%, 375,168 B)
   ### [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
     - **flash**: .text -68 B (-0.2%, 34,668 B / 131,072 B, total: 26% used)
   *No memory changes detected for:*
   - [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=aafa05a06aeae9b32e83a2f7ac589c306704432c&base=be9dc4cbaa221f99742b728ed43a11cd4ba63de4)
   


-- 
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-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org