summaryrefslogtreecommitdiff
path: root/src/thread.c
diff options
context:
space:
mode:
authorRbb666 <[email protected]>2026-03-16 13:28:12 +0800
committerRbb666 <[email protected]>2026-04-07 14:49:15 +0800
commit4025c514075387813e76d959d7b43f530725705c (patch)
treeaffdaf9d257dcfa224afb546f83d014037e915dc /src/thread.c
parent29e5f61fb9a03722c5fba65a963b2d7840587de0 (diff)
[kernel]Rewrite rt_thread_get_usage to use incremental statistics based on sampling windows.
Diffstat (limited to 'src/thread.c')
-rw-r--r--src/thread.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c
index ce68579177..745e3f774f 100644
--- a/src/thread.c
+++ b/src/thread.c
@@ -277,6 +277,13 @@ static rt_err_t _thread_init(struct rt_thread *thread,
thread->system_time = 0;
#endif
+#ifdef RT_USING_CPU_USAGE_TRACER
+ thread->user_time = 0;
+ thread->system_time = 0;
+ thread->total_time_prev = 0;
+ thread->cpu_usage = 0;
+#endif /* RT_USING_CPU_USAGE_TRACER */
+
#ifdef RT_USING_PTHREADS
thread->pthread_data = RT_NULL;
#endif /* RT_USING_PTHREADS */