You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "yushuailong (via GitHub)" <gi...@apache.org> on 2026/09/06 16:03:56 UTC
[PR] sched/critmonitor: Fix context switch state tracking [nuttx]
yushuailong opened a new pull request, #20066:
URL: https://github.com/apache/nuttx/pull/20066
## Summary
Commit b2a69ba781 merged the critical monitor suspend and resume paths into `nxsched_switch_critmon()`, but introduced two state tracking problems:
* It reintroduced the obsolete `premp_start` field name. The field was previously renamed to `preemp_start`, causing configurations with preemption monitoring enabled to fail to build.
* It assigned the current timestamp to `to->run_time` instead of `to->run_start`. This overwrote the accumulated runtime and left a stale start timestamp for the next context-switch calculation when `CONFIG_SCHED_CPULOAD_CRITMONITOR` was disabled.
This PR corrects the preemption field reference, restores the target thread's `run_start` timestamp, and updates the GDB TCB protocol annotations to match the current `struct tcb_s` fields.
## Impact
Bug fix only; no new features.
## Testing
Host: macOS 25.6 (arm64), Apple clang version 21.0.0
Target: sim:ostest
Build: clean, no warnings/errors introduced by this change.
ostest run (5 loops, CONFIG_TESTING_OSTEST_LOOPS=5, auto poweroff):
$ ./nuttx
stdio_test: write fd=1
stdio_test: Standard I/O Check: printf
stdio_test: write fd=2
stdio_test: Standard I/O Check: fprintf to stderr
ostest_main: putenv(Variable1=BadValue3)
ostest_main: setenv(Variable1, GoodValue1, TRUE)
ostest_main: setenv(Variable2, BadValue1, FALSE)
ostest_main: setenv(Variable2, GoodValue2, TRUE)
ostest_main: setenv(Variable3, GoodValue3, FALSE)
ostest_main: setenv(Variable3, BadValue2, FALSE)
show_variable: Variable=Variable1 has value=GoodValue1
show_variable: Variable=Variable2 has value=GoodValue2
show_variable: Variable=Variable3 has value=GoodValue3
ostest_main: Started user_main at PID=5
...
Final memory usage:
VARIABLE BEFORE AFTER
======== ======== ========
arena 4000000 4000000
ordblks 2 7
mxordblk 3faaaa0 3faaaa0
uordblks 452e0 457c0
fordblks 3fbad20 3fba840
user_main: Exiting
ostest_main: Exiting with status 0
Full log: 52364 lines, no FAILED / ASSERT / PANIC; final heap statistics
match the baseline (no leaks introduced).
--
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/critmonitor: Fix context switch state tracking [nuttx]
Posted by "yushuailong (via GitHub)" <gi...@apache.org>.
yushuailong commented on PR #20066:
URL: https://github.com/apache/nuttx/pull/20066#issuecomment-5578609817
> @yushuailong nice catch.
>
> Could you please help us adding some Documentation about the critical monitor?
>
> It is empty: https://nuttx.apache.org/docs/latest/applications/system/crimon/index.html
>
> The there is none reference to "nxsched_switch_critmon" https://nuttx.apache.org/docs/latest/search.html?q=nxsched_switch_critmon&check_keywords=yes&area=default
Thanks, @acassis. I submitted #20086 to address this.
The empty page was an obsolete `crimon` typo. The new PR removes it, updates the correct `critmon` documentation, and documents nxsched_switch_critmon()`.
--
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/critmonitor: Fix context switch state tracking [nuttx]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20066:
URL: https://github.com/apache/nuttx/pull/20066#issuecomment-5560477976
<!-- membrowse-pr-comment -->
## <img src="https://membrowse.com/membrowse-logo.svg" height="24" align="top"> MemBrowse Memory Report
*No memory changes detected for:*
- [arduino-mega2560](https://membrowse.com/public/apache/nuttx/target/arduino-mega2560/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [esp32-devkitc](https://membrowse.com/public/apache/nuttx/target/esp32-devkitc/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [hifive1-revb](https://membrowse.com/public/apache/nuttx/target/hifive1-revb/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [mirtoo](https://membrowse.com/public/apache/nuttx/target/mirtoo/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [qemu-armv8a](https://membrowse.com/public/apache/nuttx/target/qemu-armv8a/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [qemu-intel64](https://membrowse.com/public/apache/nuttx/target/qemu-intel64/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [rx65n-rsk2mb](https://membrowse.com/public/apache/nuttx/target/rx65n-rsk2mb/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [s698pm-dkit](https://membrowse.com/public/apache/nuttx/target/s698pm-dkit/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
- [stm32-nucleo-f103rb](https://membrowse.com/public/apache/nuttx/target/stm32-nucleo-f103rb/compare?head=64bb531f50b297e63b7117f145303008ae28a3fa&base=2a6a86cb68d9e665580aadc395707af002ed1ac5)
--
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/critmonitor: Fix context switch state tracking [nuttx]
Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 merged PR #20066:
URL: https://github.com/apache/nuttx/pull/20066
--
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/critmonitor: Fix context switch state tracking [nuttx]
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on PR #20066:
URL: https://github.com/apache/nuttx/pull/20066#issuecomment-5571040215
@yushuailong nice catch.
Could you please help us adding some Documentation about the critical monitor?
It is empty: https://nuttx.apache.org/docs/latest/applications/system/crimon/index.html
The there is none reference to "nxsched_switch_critmon"
https://nuttx.apache.org/docs/latest/search.html?q=nxsched_switch_critmon&check_keywords=yes&area=default
--
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