Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Fix snafu which caused the clock t...



details:   https://anonhg.NetBSD.org/src/rev/01061fcbf6df
branches:  trunk
changeset: 754326:01061fcbf6df
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Apr 28 00:32:30 2010 +0000

description:
Fix snafu which caused the clock to travel lightspeed.

diffstat:

 sys/rump/librump/rumpkern/intr.c |  34 +++++++++++++++++++++-------------
 1 files changed, 21 insertions(+), 13 deletions(-)

diffs (90 lines):

diff -r e2ea9253d614 -r 01061fcbf6df sys/rump/librump/rumpkern/intr.c
--- a/sys/rump/librump/rumpkern/intr.c  Tue Apr 27 23:33:14 2010 +0000
+++ b/sys/rump/librump/rumpkern/intr.c  Wed Apr 28 00:32:30 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.25 2010/04/27 23:30:29 pooka Exp $  */
+/*     $NetBSD: intr.c,v 1.26 2010/04/28 00:32:30 pooka Exp $  */
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.25 2010/04/27 23:30:29 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.26 2010/04/28 00:32:30 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -63,11 +63,6 @@
        LIST_HEAD(, softint) si_pending;
 };
 
-/* rumpuser structures since we call rumpuser interfaces directly */
-static struct rumpuser_cv *clockcv;
-static struct rumpuser_mtx *clockmtx;
-static struct timespec clockbase, clockup;
-
 kcondvar_t lbolt; /* Oh Kath Ra */
 
 static u_int ticks;
@@ -95,11 +90,15 @@
 static void
 doclock(void *noarg)
 {
+       struct timespec clockbase, clockup;
        struct timespec thetick, curtime;
+       struct rumpuser_cv *clockcv;
+       struct rumpuser_mtx *clockmtx;
        uint64_t sec, nsec;
        int error;
        extern int hz;
 
+       memset(&clockup, 0, sizeof(clockup));
        rumpuser_gettime(&sec, &nsec, &error);
        clockbase.tv_sec = sec;
        clockbase.tv_nsec = nsec;
@@ -107,6 +106,10 @@
        thetick.tv_sec = 0;
        thetick.tv_nsec = 1000000000/hz;
 
+       /* XXX: dummies */
+       rumpuser_cv_init(&clockcv);
+       rumpuser_mutex_init(&clockmtx);
+
        rumpuser_mutex_enter(clockmtx);
        for (;;) {
                callout_hardclock();
@@ -115,12 +118,19 @@
                while (rumpuser_cv_timedwait(clockcv, clockmtx,
                    curtime.tv_sec, curtime.tv_nsec) == 0)
                        continue;
-               timespecadd(&clockup, &thetick, &clockup);
+
+               /* XXX: sync with a) virtual clock b) host clock */
                timespecadd(&clockup, &clockbase, &curtime);
-               
-               /* if !maincpu: continue */
-               if (curcpu()->ci_index != 0)
+               timespecadd(&clockup, &thetick, &clockup);
+
+#if 0
+               /* CPU_IS_PRIMARY is MD and hence unreliably correct here */
+               if (!CPU_IS_PRIMARY(curcpu()))
                        continue;
+#else
+               if (curcpu()->ci_index == 0)
+                       continue;
+#endif
 
                if ((++ticks % hz) == 0) {
                        cv_broadcast(&lbolt);
@@ -197,8 +207,6 @@
 {
 
        rumpuser_mutex_init(&si_mtx);
-       rumpuser_cv_init(&clockcv);
-       rumpuser_mutex_init(&clockmtx);
        cv_init(&lbolt, "oh kath ra");
 }
 



Home | Main Index | Thread Index | Old Index