feat: 增加线程启动计数与切换时间戳,调整线程列表输出调整输出格式
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
增加线程运行日志 线程计数与上次执行时间计数 方便跟踪运行情况
你的解决方案是什么 (what is your solution)
- 在可配置宏
RT_USING_CPU_USAGE_TRACER增加两个参数 ctx_last_time ctx_count - 在cmd中增加日志打印
- 打印常量字符串的rt_kprintf 改为rt_kputs
注意
SMP 部分我未用过,不确定这样是否合适 单核心M4上已经验证
thread pri status sp stack size max used left tick error tcb addr usage count last time
---------------- --- ------- ---------- ---------- ------ ---------- ------- ---------- ----- -------- ----------
uart2 18 suspend 0x0000019c 0x00001000 12% 0x00000064 EINTRPT 0xa0049080 0% 63 935
uart4 20 suspend 0x000000a4 0x00001000 07% 0x00000064 EINTRPT 0xa0046828 0% 5 715
uart3 18 suspend 0x000000cc 0x00001000 06% 0x00000064 EINTRPT 0xa0043e88 0% 56 945
can_rx 25 suspend 0x000000bc 0x00000800 21% 0x00000003 EINTRPT 0xa0041cc8 3% 34 926
tshell 20 running 0x00000234 0x00001000 16% 0x00000002 OK 0xa0040770 1% 12 948
LVGL 20 ready 0x00000124 0x00002000 36% 0x00000004 ETIMOUT 0x10009d04 38% 163 952
tidle0 31 ready 0x0000007c 0x00000100 48% 0x0000001c OK 0x10009c4c 44% 141 929
timer 4 suspend 0x0000010c 0x00000400 46% 0x00000005 EINTRPT 0x10009dbc 0% 117 948
main 10 suspend 0x00000144 0x00000800 25% 0x00000010 EINTRPT 0xa003fc50 10% 1 1
msh >ps
thread pri status sp stack size max used left tick error tcb addr usage count last time
---------------- --- ------- ---------- ---------- ------ ---------- ------- ---------- ----- -------- ----------
uart2 18 suspend 0x0000019c 0x00001000 12% 0x00000064 EINTRPT 0xa0049080 0% 6677 100145
uart4 20 suspend 0x000000a4 0x00001000 07% 0x00000064 EINTRPT 0xa0046828 0% 352 99952
uart3 18 suspend 0x000000cc 0x00001000 06% 0x00000064 EINTRPT 0xa0043e88 0% 9978 100165
can_rx 25 suspend 0x000000bc 0x00000800 24% 0x00000002 EINTRPT 0xa0041cc8 5% 4907 100123
tshell 20 running 0x00000234 0x00001000 16% 0x0000000a OK 0xa0040770 0% 24 100166
LVGL 20 suspend 0x00000124 0x00002000 38% 0x0000000a EINTRPT 0x10009d04 34% 26873 100166
tidle0 31 ready 0x0000004c 0x00000100 48% 0x0000001c OK 0x10009c4c 58% 26699 100158
timer 4 suspend 0x0000010c 0x00000400 46% 0x00000002 EINTRPT 0x10009dbc 0% 4870 100154
main 10 suspend 0x00000144 0x00000800 25% 0x00000010 EINTRPT 0xa003fc50 0% 101 100105
请提供验证的bsp和config (provide the config and bsp)
- BSP:
- .config:
- action:
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
- [ ] 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
- [x] 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
- [x] 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
- [x] 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other styles
- [x] 没有垃圾代码,代码尽量精简,不包含
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up - [x] 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
- [x] 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
- [x] 代码是高质量的 Code in this PR is of high quality
- [x] 已经使用formatting 等源码格式化工具确保格式符合RT-Thread代码规范 This PR complies with RT-Thread code specification
- [ ] 如果是新增bsp, 已经添加ci检查到.github/ALL_BSP_COMPILE.json 详细请参考链接BSP自查
📌 Code Review Assignment
🏷️ Tag: components
Reviewers: Maihuanyi
Changed Files (Click to expand)
- components/finsh/cmd.c
🏷️ Tag: kernel
Reviewers: GorrayLi ReviewSun hamburger-os lianux-mm wdfk-prog xu18838022837
Changed Files (Click to expand)
- src/scheduler_mp.c
- src/scheduler_up.c
📊 Current Review Status (Last Updated: 2025-09-12 17:06 CST)
- ⌛ GorrayLi Pending Review
- ⌛ Maihuanyi Pending Review
- ⌛ ReviewSun Pending Review
- ⌛ hamburger-os Pending Review
- ⌛ lianux-mm Pending Review
- ⌛ wdfk-prog Pending Review
- ⌛ xu18838022837 Pending Review
📝 Review Instructions
-
维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态 Maintainers can refresh the review status by clicking here: 🔄 Refresh Status
-
确认审核通过后评论
LGTM/lgtmCommentLGTM/lgtmafter confirming approval -
PR合并前需至少一位维护者确认 PR must be confirmed by at least one maintainer before merging
ℹ️ 刷新CI状态操作需要具备仓库写入权限。 ℹ️ Refresh CI status operation requires repository Write permission.
注意空格代码对齐。麻烦改一下
cmd.c的289行没对齐
LGTM
这个功能有什么作用呢?感觉查看计数的方法并不是很直观
这个功能有什么作用呢?感觉查看计数的方法并不是很直观
count计数功能,可以帮助统计 消费者线程执行次数 活跃度 实际执行频率
last time 记录上次执行的时间, 排查线程是否被阻塞 锁死时间 以及实时性判定
它是占用率表现的信息补充,更加细节的了解线程的执行情况
我也感觉切换次数+切换时间这两个原始指标看起来不太直观。 切换次数换成累计运行时间,或者占用比例,是否是更好的选择。
我也感觉切换次数+切换时间这两个原始指标看起来不太直观。 切换次数换成累计运行时间,或者占用比例,是否是更好的选择。
累计运行时间里面已经有了 thread->user_time
stack size,left tick 现在是十六进制的,是否改为10进制.我认为这样更直观点
last time,感觉是一份参考,或者说非常弱的参考 (实时系统不那么看这份last time)。感觉这样修改意义不大呢