diff options
author | Richard Braun <rbraun@sceen.net> | 2014-09-16 20:31:35 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2014-09-16 20:31:35 +0200 |
commit | 18478032a4e6b3c475a2b37227808bf5fa4a870b (patch) | |
tree | 7f505f0447d8676342320b0710161c3963c9b6ee /kern | |
parent | c1e776e211b9f365c2f7eb66614a00621ba36dfb (diff) |
kern/task: make task_info report thread states
Diffstat (limited to 'kern')
-rw-r--r-- | kern/task.c | 6 | ||||
-rw-r--r-- | kern/thread.c | 15 | ||||
-rw-r--r-- | kern/thread.h | 5 |
3 files changed, 23 insertions, 3 deletions
diff --git a/kern/task.c b/kern/task.c index 76c32299..bb425901 100644 --- a/kern/task.c +++ b/kern/task.c @@ -136,9 +136,9 @@ task_info(struct task *task) printk("task: name: %s, threads:\n", task->name); list_for_each_entry(&task->threads, thread, task_node) - printk("task: %s: %p %.2s:%02u %s\n", task->name, thread, - thread_schedclass_to_str(thread), thread_schedprio(thread), - thread->name); + printk("task: %s: %p %c %.2s:%02u %s\n", task->name, thread, + thread_state_to_chr(thread), thread_schedclass_to_str(thread), + thread_schedprio(thread), thread->name); spinlock_unlock(&task->lock); } diff --git a/kern/thread.c b/kern/thread.c index 33707fd7..fdf2fc3c 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2068,6 +2068,21 @@ thread_tick_intr(void) spinlock_unlock(&runq->lock); } +char +thread_state_to_chr(const struct thread *thread) +{ + switch (thread->state) { + case THREAD_RUNNING: + return 'R'; + case THREAD_SLEEPING: + return 'S'; + case THREAD_DEAD: + return 'Z'; + default: + panic("thread: unknown state"); + } +} + const char * thread_schedclass_to_str(const struct thread *thread) { diff --git a/kern/thread.h b/kern/thread.h index 5206699a..60dc19c2 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -348,6 +348,11 @@ void thread_schedule_intr(void); void thread_tick_intr(void); /* + * Return a character representation of the state of a thread. + */ +char thread_state_to_chr(const struct thread *thread); + +/* * Return a string representation of the scheduling class of a thread. */ const char * thread_schedclass_to_str(const struct thread *thread); |