kernel: add a new API for setting thread names
Added k_thread_name_set() and enable thread name setting when declaring static threads. This is enabled only when THREAD_MONITOR is used. System threads get a name by default. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
3a117c220a
commit
57554055d2
8 changed files with 113 additions and 24 deletions
|
@ -539,6 +539,11 @@ struct k_thread {
|
|||
struct k_thread *next_thread;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_THREAD_NAME)
|
||||
/* Thread name */
|
||||
const char *name;
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_THREAD_CUSTOM_DATA
|
||||
/** crude thread-local storage */
|
||||
void *custom_data;
|
||||
|
@ -914,11 +919,12 @@ struct _static_thread_data {
|
|||
u32_t init_options;
|
||||
s32_t init_delay;
|
||||
void (*init_abort)(void);
|
||||
const char *init_name;
|
||||
};
|
||||
|
||||
#define _THREAD_INITIALIZER(thread, stack, stack_size, \
|
||||
entry, p1, p2, p3, \
|
||||
prio, options, delay, abort) \
|
||||
prio, options, delay, abort, tname) \
|
||||
{ \
|
||||
.init_thread = (thread), \
|
||||
.init_stack = (stack), \
|
||||
|
@ -931,6 +937,7 @@ struct _static_thread_data {
|
|||
.init_options = (options), \
|
||||
.init_delay = (delay), \
|
||||
.init_abort = (abort), \
|
||||
.init_name = STRINGIFY(tname), \
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -977,7 +984,7 @@ struct _static_thread_data {
|
|||
_THREAD_INITIALIZER(&_k_thread_obj_##name, \
|
||||
_k_thread_stack_##name, stack_size, \
|
||||
entry, p1, p2, p3, prio, options, delay, \
|
||||
NULL); \
|
||||
NULL, name); \
|
||||
const k_tid_t name = (k_tid_t)&_k_thread_obj_##name
|
||||
|
||||
/**
|
||||
|
@ -1223,10 +1230,28 @@ __syscall void k_thread_custom_data_set(void *value);
|
|||
*/
|
||||
__syscall void *k_thread_custom_data_get(void);
|
||||
|
||||
/**
|
||||
* @brief Set current thread name
|
||||
*
|
||||
* Set the name of the thread to be used when THREAD_MONITOR is enabled for
|
||||
* tracing and debugging.
|
||||
*
|
||||
*/
|
||||
__syscall void k_thread_name_set(k_tid_t thread_id, const char *value);
|
||||
|
||||
/**
|
||||
* @brief Get thread name
|
||||
*
|
||||
* Get the name of a thread
|
||||
*
|
||||
* @param thread_id Thread ID
|
||||
*
|
||||
*/
|
||||
__syscall const char *k_thread_name_get(k_tid_t thread_id);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <sys_clock.h>
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue