diff options
author | Richard Braun <rbraun@sceen.net> | 2018-07-07 15:10:20 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2018-07-07 15:10:20 +0200 |
commit | 6942b9370e09caccfb39df58f8834601b6e5af9e (patch) | |
tree | 607b8ecdfcccb74791e4ab57ef7c000c3865c648 | |
parent | 0c0e2a02a42a8161e1b8dc1e1943fe5057ecb3a3 (diff) |
kern/thread: add thread name accessor
-rw-r--r-- | arch/x86/machine/cpu.c | 3 | ||||
-rw-r--r-- | kern/task.c | 4 | ||||
-rw-r--r-- | kern/thread.h | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/arch/x86/machine/cpu.c b/arch/x86/machine/cpu.c index fc8fde3f..225f6483 100644 --- a/arch/x86/machine/cpu.c +++ b/arch/x86/machine/cpu.c @@ -445,8 +445,7 @@ cpu_show_thread(void) thread = thread_self(); - /* TODO Thread name accessor */ - printf("cpu: interrupted thread: %p (%s)\n", thread, thread->name); + printf("cpu: interrupted thread: %p (%s)\n", thread, thread_name(thread)); } #ifdef __LP64__ diff --git a/kern/task.c b/kern/task.c index 3ad863bd..aaa30f44 100644 --- a/kern/task.c +++ b/kern/task.c @@ -212,7 +212,7 @@ task_lookup_thread(struct task *task, const char *name) spinlock_lock(&task->lock); list_for_each_entry(&task->threads, thread, task_node) { - if (strcmp(thread->name, name) == 0) { + if (strcmp(thread_name(thread), name) == 0) { thread_ref(thread); spinlock_unlock(&task->lock); return thread; @@ -263,7 +263,7 @@ task_info(struct task *task) thread_sched_class_to_str(thread_user_sched_class(thread)), thread_user_priority(thread), thread_real_global_priority(thread), - thread->name); + thread_name(thread)); } spinlock_unlock(&task->lock); diff --git a/kern/thread.h b/kern/thread.h index fd729b3d..49d8b109 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -712,6 +712,12 @@ thread_get_specific(unsigned int key) return thread_tsd_get(thread_self(), key); } +static inline const char * +thread_name(const struct thread *thread) +{ + return thread->name; +} + #ifdef CONFIG_PERFMON static inline struct perfmon_td * thread_get_perfmon_td(struct thread *thread) |