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 Move routines related to kernel lo...
details: https://anonhg.NetBSD.org/src/rev/04773526fc6c
branches: trunk
changeset: 754980:04773526fc6c
user: pooka <pooka%NetBSD.org@localhost>
date: Tue May 18 15:12:19 2010 +0000
description:
Move routines related to kernel locking and scheduling from
locks.c to klock.c.
No functional change.
diffstat:
sys/rump/librump/rumpkern/Makefile.rumpkern | 8 +-
sys/rump/librump/rumpkern/klock.c | 145 ++++++++++++++++++++++++++++
sys/rump/librump/rumpkern/locks.c | 110 +--------------------
3 files changed, 151 insertions(+), 112 deletions(-)
diffs (299 lines):
diff -r 12f156560544 -r 04773526fc6c sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern Tue May 18 15:10:41 2010 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern Tue May 18 15:12:19 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.rumpkern,v 1.84 2010/05/11 22:21:05 pooka Exp $
+# $NetBSD: Makefile.rumpkern,v 1.85 2010/05/18 15:12:19 pooka Exp $
#
.include "${RUMPTOP}/Makefile.rump"
@@ -15,9 +15,9 @@
#
# Source modules, first the ones specifically implemented for librump.
#
-SRCS= rump.c rumpcopy.c emul.c intr.c kobj_rename.c locks.c \
- ltsleep.c memalloc.c scheduler.c signals.c sleepq.c \
- sysproxy_socket.c threads.c vm.c
+SRCS= rump.c rumpcopy.c emul.c intr.c klock.c kobj_rename.c \
+ locks.c ltsleep.c memalloc.c scheduler.c signals.c \
+ sleepq.c sysproxy_socket.c threads.c vm.c
vers.c: ${RUMPTOP}/../conf/newvers.sh ${RUMPTOP}/../conf/osrelease.sh
${_MKMSG_CREATE} vers.c
diff -r 12f156560544 -r 04773526fc6c sys/rump/librump/rumpkern/klock.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpkern/klock.c Tue May 18 15:12:19 2010 +0000
@@ -0,0 +1,145 @@
+/* $NetBSD: klock.c,v 1.1 2010/05/18 15:12:19 pooka Exp $ */
+
+/*
+ * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
+ *
+ * Development of this software was supported by the
+ * Finnish Cultural Foundation.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: klock.c,v 1.1 2010/05/18 15:12:19 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+
+#include <rump/rumpuser.h>
+
+#include "rump_private.h"
+
+/*
+ * giant lock
+ */
+
+static volatile int lockcnt;
+
+bool
+kernel_biglocked()
+{
+
+ return rumpuser_mutex_held(rump_giantlock) && lockcnt > 0;
+}
+
+void
+kernel_unlock_allbutone(int *countp)
+{
+ int minusone = lockcnt-1;
+
+ KASSERT(kernel_biglocked());
+ if (minusone) {
+ _kernel_unlock(minusone, countp);
+ }
+ KASSERT(lockcnt == 1);
+ *countp = minusone;
+
+ /*
+ * We drop lockcnt to 0 since rumpuser doesn't know that the
+ * kernel biglock is being used as the interlock for cv in
+ * tsleep.
+ */
+ lockcnt = 0;
+}
+
+void
+kernel_ununlock_allbutone(int nlocks)
+{
+
+ KASSERT(rumpuser_mutex_held(rump_giantlock) && lockcnt == 0);
+ lockcnt = 1;
+ _kernel_lock(nlocks);
+}
+
+void
+_kernel_lock(int nlocks)
+{
+
+ while (nlocks--) {
+ if (!rumpuser_mutex_tryenter(rump_giantlock)) {
+ struct lwp *l = curlwp;
+
+ rump_unschedule_cpu1(l, NULL);
+ rumpuser_mutex_enter_nowrap(rump_giantlock);
+ rump_schedule_cpu(l);
+ }
+ lockcnt++;
+ }
+}
+
+void
+_kernel_unlock(int nlocks, int *countp)
+{
+
+ if (!rumpuser_mutex_held(rump_giantlock)) {
+ KASSERT(nlocks == 0);
+ if (countp)
+ *countp = 0;
+ return;
+ }
+
+ if (countp)
+ *countp = lockcnt;
+ if (nlocks == 0)
+ nlocks = lockcnt;
+ if (nlocks == -1) {
+ KASSERT(lockcnt == 1);
+ nlocks = 1;
+ }
+ KASSERT(nlocks <= lockcnt);
+ while (nlocks--) {
+ lockcnt--;
+ rumpuser_mutex_exit(rump_giantlock);
+ }
+}
+
+void
+rump_user_unschedule(int nlocks, int *countp, void *interlock)
+{
+
+ _kernel_unlock(nlocks, countp);
+ /*
+ * XXX: technically we should unschedule_cpu1() here, but that
+ * requires rump_intr_enter/exit to be implemented.
+ */
+ rump_unschedule_cpu_interlock(curlwp, interlock);
+}
+
+void
+rump_user_schedule(int nlocks, void *interlock)
+{
+
+ rump_schedule_cpu_interlock(curlwp, interlock);
+
+ if (nlocks)
+ _kernel_lock(nlocks);
+}
diff -r 12f156560544 -r 04773526fc6c sys/rump/librump/rumpkern/locks.c
--- a/sys/rump/librump/rumpkern/locks.c Tue May 18 15:10:41 2010 +0000
+++ b/sys/rump/librump/rumpkern/locks.c Tue May 18 15:12:19 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locks.c,v 1.40 2010/05/18 14:58:42 pooka Exp $ */
+/* $NetBSD: locks.c,v 1.41 2010/05/18 15:12:19 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.40 2010/05/18 14:58:42 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.41 2010/05/18 15:12:19 pooka Exp $");
#include <sys/param.h>
#include <sys/kmem.h>
@@ -281,109 +281,3 @@
return RUMPCV(cv) != NULL;
}
-
-/*
- * giant lock
- */
-
-static volatile int lockcnt;
-
-bool
-kernel_biglocked()
-{
-
- return rumpuser_mutex_held(rump_giantlock) && lockcnt > 0;
-}
-
-void
-kernel_unlock_allbutone(int *countp)
-{
- int minusone = lockcnt-1;
-
- KASSERT(kernel_biglocked());
- if (minusone) {
- _kernel_unlock(minusone, countp);
- }
- KASSERT(lockcnt == 1);
- *countp = minusone;
-
- /*
- * We drop lockcnt to 0 since rumpuser doesn't know that the
- * kernel biglock is being used as the interlock for cv in
- * tsleep.
- */
- lockcnt = 0;
-}
-
-void
-kernel_ununlock_allbutone(int nlocks)
-{
-
- KASSERT(rumpuser_mutex_held(rump_giantlock) && lockcnt == 0);
- lockcnt = 1;
- _kernel_lock(nlocks);
-}
-
-void
-_kernel_lock(int nlocks)
-{
-
- while (nlocks--) {
- if (!rumpuser_mutex_tryenter(rump_giantlock)) {
- struct lwp *l = curlwp;
-
- rump_unschedule_cpu1(l, NULL);
- rumpuser_mutex_enter_nowrap(rump_giantlock);
- rump_schedule_cpu(l);
- }
- lockcnt++;
- }
-}
-
-void
-_kernel_unlock(int nlocks, int *countp)
-{
-
- if (!rumpuser_mutex_held(rump_giantlock)) {
- KASSERT(nlocks == 0);
- if (countp)
- *countp = 0;
- return;
- }
-
- if (countp)
- *countp = lockcnt;
- if (nlocks == 0)
- nlocks = lockcnt;
- if (nlocks == -1) {
- KASSERT(lockcnt == 1);
- nlocks = 1;
- }
- KASSERT(nlocks <= lockcnt);
- while (nlocks--) {
- lockcnt--;
- rumpuser_mutex_exit(rump_giantlock);
- }
-}
-
-void
-rump_user_unschedule(int nlocks, int *countp, void *interlock)
-{
-
- _kernel_unlock(nlocks, countp);
- /*
- * XXX: technically we should unschedule_cpu1() here, but that
- * requires rump_intr_enter/exit to be implemented.
- */
- rump_unschedule_cpu_interlock(curlwp, interlock);
-}
-
-void
-rump_user_schedule(int nlocks, void *interlock)
-{
-
- rump_schedule_cpu_interlock(curlwp, interlock);
-
- if (nlocks)
- _kernel_lock(nlocks);
-}
Home |
Main Index |
Thread Index |
Old Index