Source-Changes-HG archive

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

[src/trunk]: src/tests/rump/kernspace Tweak use of cv_timedwait



details:   https://anonhg.NetBSD.org/src/rev/a52098988d38
branches:  trunk
changeset: 828701:a52098988d38
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Thu Dec 28 04:36:15 2017 +0000

description:
Tweak use of cv_timedwait

- Handle its return value
- Specify more appropriate time-out periods (2 ticks is too short)

diffstat:

 tests/rump/kernspace/workqueue.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 78d27b8035da -r a52098988d38 tests/rump/kernspace/workqueue.c
--- a/tests/rump/kernspace/workqueue.c  Thu Dec 28 03:39:48 2017 +0000
+++ b/tests/rump/kernspace/workqueue.c  Thu Dec 28 04:36:15 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: workqueue.c,v 1.1 2017/09/29 12:42:36 maya Exp $       */
+/*     $NetBSD: workqueue.c,v 1.2 2017/12/28 04:36:15 ozaki-r Exp $    */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: workqueue.c,v 1.1 2017/09/29 12:42:36 maya Exp $");
+__RCSID("$NetBSD: workqueue.c,v 1.2 2017/12/28 04:36:15 ozaki-r Exp $");
 #endif /* !lint */
 
 #include <sys/param.h>
@@ -83,9 +83,12 @@
 
 #define ITERATIONS 12435
        for (size_t i = 0; i < ITERATIONS; ++i) {
+               int e;
                workqueue_enqueue(sc->wq, &sc->wk, NULL);
                mutex_enter(&sc->mtx);
-               cv_timedwait(&sc->cv, &sc->mtx, 2);
+               e = cv_timedwait(&sc->cv, &sc->mtx, hz * 2);
+               if (e != 0)
+                       panic("cv_timedwait timed out (i=%lu)", i);
                mutex_exit(&sc->mtx);
        }
 



Home | Main Index | Thread Index | Old Index