kernel: Add k_thread_runtime_stats_is_enabled function#80450
kernel: Add k_thread_runtime_stats_is_enabled function#80450rruuaanng wants to merge 2 commits intozephyrproject-rtos:mainfrom
Conversation
fc52903 to
075a033
Compare
70b4aa0 to
04e6d25
Compare
cfriedt
left a comment
There was a problem hiding this comment.
Thanks for all of the POSIX clock work.
Just a question / suggestion regarding runtime function call overhead.
cfriedt
left a comment
There was a problem hiding this comment.
Just some suggestions around CONFIG_POSIX_THREAD_CPUTIME
5302a73 to
e9323cc
Compare
|
I've made change, Please riewer again! |
peter-mitsis
left a comment
There was a problem hiding this comment.
Kernel side seems reasonable to me.
|
@rruuaanng - Looks like this has conflicts that need to get resolved. |
andyross
left a comment
There was a problem hiding this comment.
Tiny nitpick. I'll let others weigh in on the posix changes, seems like that could be a separate PR? +1 for the meat of the PR.
| * @param thread ID of thread | ||
| * @return true if usage statistics are enabled for the given thread, otherwise false | ||
| */ | ||
| bool k_thread_runtime_stats_is_enabled(k_tid_t thread); |
There was a problem hiding this comment.
If this just depends on the thread struct, that header appears in the include paths already. You can make this inline without worry and save a few code bytes for users.
There was a problem hiding this comment.
Maybe we should stick to the existing API style? It looks like there are no static inline functions in kernel.h.
|
I will open a new PR to finish the POSIX part, just to avoid any confusion. |
|
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>
Add test for 'k_thread_runtime_stats_is_enabled(tid)'. Signed-off-by: James Roy <rruuaanng@outlook.com>
|



Add 'k_thread_runtime_stats_is_enabled' to 'usage.c', which's used to check whether runtime statistics collection is enabled for a thread.
It can determine whether the thread has enabled runtime statistics collection when the program is running. It allows users to add conditional statements based on this function when using it.
for example:
And it can provide a complete support when similar operations are needed. for example
enable,disable,is_enabled.For example, its use in the implementation of CLOCK_THREAD_CPUTIME_ID actually lacks k_thread_runtime_stats_is_enabled, which makes the entire function impossible to implement safely. It is necessary.
..