From: Antti Kantee Date: Mon, 20 Apr 2015 13:26:52 +0000 (+0000) Subject: Unify domain blocking part in scheduler implementations X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=df3d29b92a5098a02701ff0cb02320f5335b7e45;p=people%2Fliuw%2Frumprun.git Unify domain blocking part in scheduler implementations --- diff --git a/platform/baremetal/sched.c b/platform/baremetal/sched.c index b410e12..f1e35fd 100644 --- a/platform/baremetal/sched.c +++ b/platform/baremetal/sched.c @@ -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); diff --git a/platform/xen/xen/sched.c b/platform/xen/xen/sched.c index 444eb6f..ea95837 100644 --- a/platform/xen/xen/sched.c +++ b/platform/xen/xen/sched.c @@ -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);