Skip to content

Commit 75c5e20

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 685511a commit 75c5e20

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
@@ -6576,6 +6576,16 @@ int k_thread_runtime_stats_enable(k_tid_t thread);
65766576
*/
65776577
int k_thread_runtime_stats_disable(k_tid_t thread);
65786578

6579+
/**
6580+
* @brief Check if runtime statistics gathering is enabled for a thread
6581+
*
6582+
* This routine checks whether the specified thread has enabled runtime statistics.
6583+
*
6584+
* @param thread ID of thread
6585+
* @return true if usage statistics are enabled for the given thread, otherwise false
6586+
*/
6587+
bool k_thread_runtime_stats_is_enabled(k_tid_t thread);
6588+
65796589
/**
65806590
* @brief Enable gathering of system runtime statistics
65816591
*

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)