From 0863c9acd735b947d9874a9b73044202b1074e51 Mon Sep 17 00:00:00 2001 From: Antti Kantee Date: Mon, 20 Apr 2015 10:47:21 +0000 Subject: [PATCH] Add a scheduler debug routine for dumping the thread queue. --- include/bmk-core/sched.h | 2 ++ platform/baremetal/sched.c | 22 ++++++++++++++++++++++ platform/xen/xen/sched.c | 21 +++++++++++++++++++++ 3 files changed, 45 insertions(+) diff --git a/include/bmk-core/sched.h b/include/bmk-core/sched.h index 6b19093..076217b 100644 --- a/include/bmk-core/sched.h +++ b/include/bmk-core/sched.h @@ -42,6 +42,8 @@ void bmk_sched_init(void); void bmk_sched(void); void bmk_sched_yield(void); +void bmk_sched_dumpqueue(void); + struct bmk_thread *bmk_sched_create(const char *, void *, int, void (*)(void *), void *, void *, unsigned long); diff --git a/platform/baremetal/sched.c b/platform/baremetal/sched.c index 7d54c75..363cc81 100644 --- a/platform/baremetal/sched.c +++ b/platform/baremetal/sched.c @@ -68,6 +68,7 @@ #include #include +#include #include #include #include @@ -150,6 +151,14 @@ stackfree(struct bmk_thread *thread) bmk_platform_freepg2(thread->bt_stackbase, BMK_THREAD_STACK_PAGE_ORDER); } +static void +print_threadinfo(struct bmk_thread *thread) +{ + + bmk_printf("thread \"%s\" at %p, flags 0x%x\n", + thread->bt_name, thread, thread->bt_flags); +} + static void sched_switch(struct bmk_thread *prev, struct bmk_thread *next) { @@ -160,6 +169,19 @@ sched_switch(struct bmk_thread *prev, struct bmk_thread *next) bmk_cpu_sched_switch(&prev->bt_tcb, &next->bt_tcb); } + +void +bmk_sched_dumpqueue(void) +{ + struct bmk_thread *thr; + + bmk_printf("BEGIN schedqueue dump\n"); + TAILQ_FOREACH(thr, &threads, bt_entries) { + print_threadinfo(thr); + } + bmk_printf("END schedqueue dump\n"); +} + void bmk_sched(void) { diff --git a/platform/xen/xen/sched.c b/platform/xen/xen/sched.c index 8d8e8e7..f647984 100644 --- a/platform/xen/xen/sched.c +++ b/platform/xen/xen/sched.c @@ -74,6 +74,7 @@ #include #include +#include #include #include #include @@ -151,6 +152,14 @@ stackfree(struct bmk_thread *thread) bmk_platform_freepg2(thread->bt_stackbase, STACK_SIZE_PAGE_ORDER); } +static void +print_threadinfo(struct bmk_thread *thread) +{ + + bmk_printf("thread \"%s\" at %p, flags 0x%x\n", + thread->bt_name, thread, thread->bt_flags); +} + void sched_switch(struct bmk_thread *prev, struct bmk_thread *next) { @@ -167,6 +176,18 @@ bmk_sched_current(void) return arch_sched_current(); } +void +bmk_sched_dumpqueue(void) +{ + struct bmk_thread *thr; + + bmk_printf("BEGIN schedqueue dump\n"); + TAILQ_FOREACH(thr, &threads, bt_entries) { + print_threadinfo(thr); + } + bmk_printf("END schedqueue dump\n"); +} + void bmk_sched(void) { -- 2.39.5