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 pthread_cond_timedwait (and theref...



details:   https://anonhg.NetBSD.org/src/rev/992a7055743e
branches:  trunk
changeset: 750208:992a7055743e
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sun Dec 20 13:49:36 2009 +0000

description:
pthread_cond_timedwait (and therefore rumpuser_cv_timedwait) wants
an absolute time instead of a delta.  Fix bug which caused timed
tsleeps to always wake up immediately (unless the system clock was
around "0", which was not very probable ;).

diffstat:

 sys/rump/librump/rumpkern/ltsleep.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r 4786165ec518 -r 992a7055743e sys/rump/librump/rumpkern/ltsleep.c
--- a/sys/rump/librump/rumpkern/ltsleep.c       Sun Dec 20 10:57:35 2009 +0000
+++ b/sys/rump/librump/rumpkern/ltsleep.c       Sun Dec 20 13:49:36 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ltsleep.c,v 1.23 2009/12/05 22:44:08 pooka Exp $       */
+/*     $NetBSD: ltsleep.c,v 1.24 2009/12/20 13:49:36 pooka Exp $       */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ltsleep.c,v 1.23 2009/12/05 22:44:08 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ltsleep.c,v 1.24 2009/12/20 13:49:36 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -58,6 +58,7 @@
 static int
 sleeper(struct ltsleeper *ltsp, int timo)
 {
+       struct timespec ts, ticks;
        int rv, nlocks;
 
        LIST_INSERT_HEAD(&sleepers, ltsp, entries);
@@ -65,8 +66,12 @@
 
        /* protected by biglock */
        if (timo) {
+               ticks.tv_sec = timo / hz;
+               ticks.tv_nsec = (timo % hz) * (1000000000/hz);
+               nanotime(&ts);
+               timespecadd(&ts, &ticks, &ts);
                if (rumpuser_cv_timedwait(ltsp->cv, rump_giantlock,
-                   timo / hz, (timo % hz) * (1000000000/hz)) == 0)
+                   ts.tv_sec, ts.tv_nsec) == 0)
                        rv = 0;
                else
                        rv = EWOULDBLOCK;



Home | Main Index | Thread Index | Old Index