Skip to content

Commit 7c6f970

Browse files
committed
kernel: Add k_thread_runtime_stats_is_enabled function
Add 'k_thread_runtime_stats_is_enabled' function, whichs used to check whether runtime statistics collection is enabled for a thread. Signed-off-by: James Roy <rruuaanng@outlook.com>
1 parent 5cdf073 commit 7c6f970

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

include/zephyr/kernel.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6423,6 +6423,16 @@ int k_thread_runtime_stats_enable(k_tid_t thread);
64236423
*/
64246424
int k_thread_runtime_stats_disable(k_tid_t thread);
64256425

6426+
/**
6427+
* @brief Check if runtime statistics gathering is enabled for a thread
6428+
*
6429+
* This routine checks whether the specified thread has enabled runtime statistics.
6430+
*
6431+
* @param thread ID of thread
6432+
* @return true if usage statistics are enabled for the given thread, otherwise false
6433+
*/
6434+
bool k_thread_runtime_stats_is_enabled(k_tid_t thread);
6435+
64266436
/**
64276437
* @brief Enable gathering of system runtime statistics
64286438
*

kernel/usage.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ int k_thread_runtime_stats_disable(k_tid_t thread)
272272

273273
return 0;
274274
}
275+
276+
bool k_thread_runtime_stats_is_enabled(k_tid_t thread)
277+
{
278+
return thread->base.usage.track_usage;
279+
}
275280
#endif /* CONFIG_SCHED_THREAD_USAGE_ANALYSIS */
276281

277282
#ifdef CONFIG_SCHED_THREAD_USAGE_ALL

0 commit comments

Comments
 (0)