]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
Bootstrap scheduler the same way between xen and baremetal.
authorAntti Kantee <pooka@iki.fi>
Tue, 21 Apr 2015 11:26:56 +0000 (11:26 +0000)
committerAntti Kantee <pooka@iki.fi>
Tue, 21 Apr 2015 11:26:56 +0000 (11:26 +0000)
Get rid of the idle thread in Xen, it's no longer used.

platform/xen/xen/arch/x86/sched.c
platform/xen/xen/include/mini-os/sched.h
platform/xen/xen/kernel.c
platform/xen/xen/sched.c

index c9c672486c767533248d3071da3a0741fc389d64..739c41d01f5b8f97c25b11b169d7e9ec243c5dd0 100644 (file)
@@ -78,24 +78,6 @@ void dump_stack(struct thread *thread_md)
    defined in x86_[32/64].S */
 extern void _minios_entry_thread_starter(void);
 
-void run_idle_thread(void)
-{
-    /* Switch stacks and run the thread */ 
-#if defined(__i386__)
-    __asm__ __volatile__("mov %0,%%esp\n\t"
-                         "push %1\n\t" 
-                         "ret"                                            
-                         :"=m" (idle_tcb->btcb_sp)
-                         :"m" (idle_tcb->btcb_ip));
-#elif defined(__x86_64__)
-    __asm__ __volatile__("mov %0,%%rsp\n\t"
-                         "push %1\n\t" 
-                         "ret"                                            
-                         :"=m" (idle_tcb->btcb_sp)
-                         :"m" (idle_tcb->btcb_ip));
-#endif
-}
-
 void
 bmk_cpu_switch(struct bmk_tcb *prev, struct bmk_tcb *next)
 {
index 1a274088e35634e7a2d670356eb364c0a33c2c1f..f7e9ecf9b373603e4db117a4c8396a1ca36bac98 100644 (file)
@@ -1,13 +1,4 @@
 #ifndef __MINIOS_SCHED_H__
 #define __MINIOS_SCHED_H__
 
-#include <mini-os/types.h>
-
-#include <bmk-core/sched.h>
-
-extern struct bmk_tcb *idle_tcb;
-void idle_thread_fn(void *unused);
-
-void run_idle_thread(void);
-
 #endif /* __MINIOS_SCHED_H__ */
index 1aa2e045ee2c6e675bc80b230c44d8da7d44372b..c834c589cb8236980d52273ecf9d9b82ef6a7e04 100644 (file)
@@ -169,18 +169,13 @@ void _minios_start_kernel(start_info_t *si)
 
     /* Init grant tables */
     init_gnttab();
-    
-    /* Init scheduler. */
-    bmk_sched_init(NULL, NULL);
  
     /* Init XenBus */
     init_xenbus();
 
-    /* Call (possibly overridden) app_main() */
-    bmk_sched_create("main", NULL, 0, _app_main, &start_info, NULL, 0);
-
-    /* Everything initialised, start idle thread */
-    run_idle_thread();
+    /* Init scheduler. */
+    bmk_sched_init(_app_main, &start_info);
+    bmk_platform_halt("unreachable");
 }
 
 void minios_stop_kernel(void)
index 949d967ed96c201c5380b85884733ef2f3642b31..5aa83b0374e609ba5cccabbb6bcf4d642f10d9a8 100644 (file)
@@ -107,9 +107,6 @@ struct bmk_thread {
        TAILQ_ENTRY(bmk_thread) bt_entries;
 };
 
-static struct bmk_thread *idle_thread = NULL;
-struct bmk_tcb *idle_tcb;
-
 static TAILQ_HEAD(, bmk_thread) zombies = TAILQ_HEAD_INITIALIZER(zombies);
 static TAILQ_HEAD(, bmk_thread) threads = TAILQ_HEAD_INITIALIZER(threads);
 
@@ -458,23 +455,20 @@ bmk_sched_wake(struct bmk_thread *thread)
 }
 
 void
-idle_thread_fn(void *unused)
+bmk_sched_init(void (*mainfun)(void *), void *arg)
 {
+       struct bmk_thread *mainthread;
+       struct bmk_thread initthread;
 
-       for (;;) {
-               bmk_sched_block(bmk_sched_current());
-               bmk_sched();
-       }
-}
+       mainthread = bmk_sched_create("main", NULL, 0, mainfun, arg, NULL, 0);
+       if (mainthread == NULL)
+               bmk_platform_halt("failed to create main thread");
 
-void
-bmk_sched_init(void (*notused)(void *), void *arg)
-{
-       minios_printk("Initialising scheduler\n");
+       bmk_memset(&initthread, 0, sizeof(initthread));
+       bmk_strcpy(initthread.bt_name, "init");
+       sched_switch(&initthread, mainthread);
 
-       idle_thread = bmk_sched_create("Idle", NULL, 0,
-           idle_thread_fn, NULL, NULL, 0);
-       idle_tcb = &idle_thread->bt_tcb;
+       bmk_platform_halt("bmk_sched_init unreachable");
 }
 
 void