]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
Add a scheduler debug routine for dumping the thread queue.
authorAntti Kantee <pooka@iki.fi>
Mon, 20 Apr 2015 10:47:21 +0000 (10:47 +0000)
committerAntti Kantee <pooka@iki.fi>
Mon, 20 Apr 2015 10:47:21 +0000 (10:47 +0000)
include/bmk-core/sched.h
platform/baremetal/sched.c
platform/xen/xen/sched.c

index 6b19093dce002122131231bcbc3e999b600ab36d..076217bb51219978ae3f37c04b914c9b00305996 100644 (file)
@@ -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);
index 7d54c7529b09436a5ca58ef56c8ead9b1171273b..363cc81852c380010b6a9d8ce74c68add40ac00a 100644 (file)
@@ -68,6 +68,7 @@
 
 #include <bmk-core/core.h>
 #include <bmk-core/memalloc.h>
+#include <bmk-core/printf.h>
 #include <bmk-core/queue.h>
 #include <bmk-core/string.h>
 #include <bmk-core/sched.h>
@@ -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)
 {
index 8d8e8e79816d65c325804996d20e43d139c1ac9a..f647984e5961ebb6275f7e21dd805dd94e383274 100644 (file)
@@ -74,6 +74,7 @@
 
 #include <bmk-core/memalloc.h>
 #include <bmk-core/platform.h>
+#include <bmk-core/printf.h>
 #include <bmk-core/queue.h>
 #include <bmk-core/string.h>
 #include <bmk-core/sched.h>
@@ -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)
 {