diff options
| author | Fan Yang <[email protected]> | 2023-05-17 17:40:18 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-17 17:40:18 +0800 |
| commit | 48557de14897afb0965695d272d07f83f0b08c42 (patch) | |
| tree | 5a423e6603cac828c53b96d1345c9b0c0e154f84 /src/thread.c | |
| parent | 065a3e1b3aaebe18361d51124c6aa2246a97b008 (diff) | |
[include][src] Add API to get object name and thread name (#7507)
Signed-off-by: Fan YANG <[email protected]>
Co-authored-by: Man, Jianting (Meco) <[email protected]>
Diffstat (limited to 'src/thread.c')
| -rw-r--r-- | src/thread.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c index 133289738e..ad82a13550 100644 --- a/src/thread.c +++ b/src/thread.c @@ -1142,4 +1142,22 @@ rt_thread_t rt_thread_find(char *name) RTM_EXPORT(rt_thread_find); +/** + * @brief This function will return the name of the specified thread + * + * @note Please don't invoke this function in interrupt status + * + * @param thread the thread to retrieve thread name + * @param name buffer to store the thread name string + * @param name_size maximum size of the buffer to store the thread name + * + * @return If the return value is RT_EOK, the function is successfully executed + * If the return value is -RT_EINVAL, it means this operation failed + */ +rt_err_t rt_thread_get_name(rt_thread_t thread, char *name, rt_uint8_t name_size) +{ + return (thread == RT_NULL) ? -RT_EINVAL : rt_object_get_name(&thread->parent, name, name_size); +} +RTM_EXPORT(rt_thread_get_name); + /**@}*/ |
