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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]