]> xenbits.xensource.com Git - people/liuw/rumprun.git/commitdiff
Unify domain blocking part in scheduler implementations
authorAntti Kantee <pooka@iki.fi>
Mon, 20 Apr 2015 13:26:52 +0000 (13:26 +0000)
committerAntti Kantee <pooka@iki.fi>
Mon, 20 Apr 2015 13:26:52 +0000 (13:26 +0000)
platform/baremetal/sched.c
platform/xen/xen/sched.c

index b410e12e8ecbb40401376565dfcf09c3dd647f18..f1e35fd68ce2bf8385aa240f5414d0219a32b1ea 100644 (file)
@@ -187,7 +187,6 @@ void
 bmk_sched(void)
 {
        struct bmk_thread *prev, *next, *thread, *tmp;
-       bmk_time_t tm, wakeup;
        unsigned long flags;
 
        prev = bmk_sched_current();
@@ -195,7 +194,12 @@ bmk_sched(void)
 
        /* could do time management a bit better here */
        do {
+               bmk_time_t tm, wakeup;
+
+               /* block domain for max 1s */
                tm = bmk_clock_monotonic();
+               wakeup = tm + 1*1000*1000*1000ULL;
+
                next = NULL;
                TAILQ_FOREACH_SAFE(thread, &threads, bt_entries, tmp) {
                        if (!is_runnable(thread)
@@ -216,10 +220,9 @@ bmk_sched(void)
                }
                if (next)
                        break;
-               /*
-                * no runnables.  hlt for a while.
-                */
-               bmk_cpu_nanohlt();
+
+               /* sleep for a while */
+               bmk_platform_block(wakeup);
        } while (1);
 
        bmk_platform_splx(flags);
index 444eb6f9bf970c86b5b5f54369772e6120eb1486..ea9583782e0d4266a3d4ba76e008c3a251699e45 100644 (file)
@@ -207,8 +207,12 @@ bmk_sched(void)
 
        /* could do time management a bit better here */
        do {
-               s_time_t tm = NOW();
-               s_time_t wakeup = tm + SECONDS(10);
+               bmk_time_t tm, wakeup;
+
+               /* block domain for max 1s */
+               tm = bmk_clock_monotonic();
+               wakeup = tm + 1*1000*1000*1000ULL;
+
                next = NULL;
                TAILQ_FOREACH_SAFE(thread, &threads, bt_entries, tmp) {
                        if (!is_runnable(thread)
@@ -229,13 +233,10 @@ bmk_sched(void)
                }
                if (next)
                        break;
-               /*
-                * no runnables.  hlt for a while.
-                */
-               block_domain(wakeup);
-               /* handle pending events if any */
-               minios_force_evtchn_callback();
-       } while(1);
+
+               /* sleep for a while */
+               bmk_platform_block(wakeup);
+       } while (1);
 
        bmk_platform_splx(flags);