diff options
author | Richard Braun <rbraun@sceen.net> | 2014-09-09 01:43:57 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2014-09-09 01:43:57 +0200 |
commit | 0f178b0fd82ae1312a6d20b11c8bcb9980a8ac08 (patch) | |
tree | e8ef18c8d17f055a9ab7a2905ef19d7731b9dc35 | |
parent | d98a09eb52fb4d0cdc6fc9a523fde5178f183315 (diff) |
kern/task: make task_info report scheduling properties
-rw-r--r-- | kern/task.c | 4 | ||||
-rw-r--r-- | kern/thread.c | 30 | ||||
-rw-r--r-- | kern/thread.h | 12 |
3 files changed, 45 insertions, 1 deletions
diff --git a/kern/task.c b/kern/task.c index 4cc87ca7..76c32299 100644 --- a/kern/task.c +++ b/kern/task.c @@ -136,7 +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 (%s)\n", task->name, thread, thread->name); + printk("task: %s: %p %.2s:%02u %s\n", task->name, 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 67f59858..33707fd7 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -2068,6 +2068,36 @@ thread_tick_intr(void) spinlock_unlock(&runq->lock); } +const char * +thread_schedclass_to_str(const struct thread *thread) +{ + switch (thread->sched_class) { + case THREAD_SCHED_CLASS_RT: + return "rt"; + case THREAD_SCHED_CLASS_TS: + return "ts"; + case THREAD_SCHED_CLASS_IDLE: + return "idle"; + default: + panic("thread: unknown scheduling class"); + } +} + +unsigned int +thread_schedprio(const struct thread *thread) +{ + switch (thread->sched_class) { + case THREAD_SCHED_CLASS_RT: + return thread->rt_data.priority; + case THREAD_SCHED_CLASS_TS: + return thread->ts_data.priority; + case THREAD_SCHED_CLASS_IDLE: + return 0; + default: + panic("thread: unknown scheduling class"); + } +} + void thread_key_create(unsigned int *keyp, thread_dtor_fn_t dtor) { diff --git a/kern/thread.h b/kern/thread.h index d1c5f53a..5206699a 100644 --- a/kern/thread.h +++ b/kern/thread.h @@ -347,6 +347,18 @@ void thread_schedule_intr(void); */ void thread_tick_intr(void); +/* + * Return a string representation of the scheduling class of a thread. + */ +const char * thread_schedclass_to_str(const struct thread *thread); + +/* + * Return the priority of a thread. + * + * If the scheduling class doesn't use a priority, return 0. + */ +unsigned int thread_schedprio(const struct thread *thread); + static inline struct thread * thread_from_tcb(struct tcb *tcb) { |