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 Similarly to cv_wait, fail if tryi...



details:   https://anonhg.NetBSD.org/src/rev/70aaeea4195b
branches:  trunk
changeset: 755552:70aaeea4195b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Jun 09 07:54:13 2010 +0000

description:
Similarly to cv_wait, fail if trying to cv_wait_sig() without threads.

diffstat:

 sys/rump/librump/rumpkern/locks.c |  26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diffs (65 lines):

diff -r 360d2f4cbcf2 -r 70aaeea4195b sys/rump/librump/rumpkern/locks.c
--- a/sys/rump/librump/rumpkern/locks.c Wed Jun 09 05:00:25 2010 +0000
+++ b/sys/rump/librump/rumpkern/locks.c Wed Jun 09 07:54:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locks.c,v 1.41 2010/05/18 15:12:19 pooka Exp $ */
+/*     $NetBSD: locks.c,v 1.42 2010/06/09 07:54:13 pooka Exp $ */
 
 /*
  * Copyright (c) 2007, 2008 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.41 2010/05/18 15:12:19 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.42 2010/06/09 07:54:13 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -206,7 +206,7 @@
 cv_wait(kcondvar_t *cv, kmutex_t *mtx)
 {
 
-       if (rump_threads == 0)
+       if (__predict_false(rump_threads == 0))
                panic("cv_wait without threads");
        rumpuser_cv_wait(RUMPCV(cv), RUMPMTX(mtx));
 }
@@ -215,6 +215,8 @@
 cv_wait_sig(kcondvar_t *cv, kmutex_t *mtx)
 {
 
+       if (__predict_false(rump_threads == 0))
+               panic("cv_wait without threads");
        rumpuser_cv_wait(RUMPCV(cv), RUMPMTX(mtx));
        return 0;
 }
@@ -225,19 +227,19 @@
        struct timespec ts, tick;
        extern int hz;
 
-       /*
-        * XXX: this fetches rump kernel time, but rumpuser_cv_timedwait
-        * uses host time.
-        */
-       nanotime(&ts);
-       tick.tv_sec = ticks / hz;
-       tick.tv_nsec = (ticks % hz) * (1000000000/hz);
-       timespecadd(&ts, &tick, &ts);
-
        if (ticks == 0) {
                cv_wait(cv, mtx);
                return 0;
        } else {
+               /*
+                * XXX: this fetches rump kernel time, but
+                * rumpuser_cv_timedwait uses host time.
+                */
+               nanotime(&ts);
+               tick.tv_sec = ticks / hz;
+               tick.tv_nsec = (ticks % hz) * (1000000000/hz);
+               timespecadd(&ts, &tick, &ts);
+
                if (rumpuser_cv_timedwait(RUMPCV(cv), RUMPMTX(mtx),
                    ts.tv_sec, ts.tv_nsec))
                        return EWOULDBLOCK;



Home | Main Index | Thread Index | Old Index