Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumpuser reorder for better locality. no functional ...
details: https://anonhg.NetBSD.org/src/rev/b928a080fc07
branches: trunk
changeset: 786593:b928a080fc07
user: pooka <pooka%NetBSD.org@localhost>
date: Thu May 02 22:07:57 2013 +0000
description:
reorder for better locality. no functional change.
diffstat:
lib/librumpuser/rumpuser_pth.c | 128 +++++++++++++++++++++-------------------
1 files changed, 68 insertions(+), 60 deletions(-)
diffs (181 lines):
diff -r b048d671fc26 -r b928a080fc07 lib/librumpuser/rumpuser_pth.c
--- a/lib/librumpuser/rumpuser_pth.c Thu May 02 21:47:12 2013 +0000
+++ b/lib/librumpuser/rumpuser_pth.c Thu May 02 22:07:57 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser_pth.c,v 1.25 2013/05/02 21:35:19 pooka Exp $ */
+/* $NetBSD: rumpuser_pth.c,v 1.26 2013/05/02 22:07:57 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -28,7 +28,7 @@
#include "rumpuser_port.h"
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth.c,v 1.25 2013/05/02 21:35:19 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth.c,v 1.26 2013/05/02 22:07:57 pooka Exp $");
#endif /* !lint */
#include <sys/queue.h>
@@ -47,64 +47,6 @@
#include "rumpuser_int.h"
-static pthread_key_t curlwpkey;
-
-struct rumpuser_mtx {
- pthread_mutex_t pthmtx;
- struct lwp *owner;
- int flags;
-};
-
-#define RURW_AMWRITER(rw) (rw->writer == rumpuser_curlwp() \
- && rw->readers == -1)
-#define RURW_HASREAD(rw) (rw->readers > 0)
-
-#define RURW_SETWRITE(rw) \
-do { \
- assert(rw->readers == 0); \
- rw->writer = rumpuser_curlwp(); \
- rw->readers = -1; \
-} while (/*CONSTCOND*/0)
-#define RURW_CLRWRITE(rw) \
-do { \
- assert(RURW_AMWRITER(rw)); \
- rw->readers = 0; \
- rw->writer = NULL; \
-} while (/*CONSTCOND*/0)
-#define RURW_INCREAD(rw) \
-do { \
- pthread_spin_lock(&rw->spin); \
- assert(rw->readers >= 0); \
- ++(rw)->readers; \
- pthread_spin_unlock(&rw->spin); \
-} while (/*CONSTCOND*/0)
-#define RURW_DECREAD(rw) \
-do { \
- pthread_spin_lock(&rw->spin); \
- assert(rw->readers > 0); \
- --(rw)->readers; \
- pthread_spin_unlock(&rw->spin); \
-} while (/*CONSTCOND*/0)
-
-struct rumpuser_rw {
- pthread_rwlock_t pthrw;
- pthread_spinlock_t spin;
- int readers;
- struct lwp *writer;
-};
-
-struct rumpuser_cv {
- pthread_cond_t pthcv;
- int nwaiters;
-};
-
-void
-rumpuser__thrinit(void)
-{
-
- pthread_key_create(&curlwpkey, NULL);
-}
-
int
rumpuser_thread_create(void *(*f)(void *), void *arg, const char *thrname,
int joinable, int priority, int cpuidx, void **ptcookie)
@@ -170,6 +112,12 @@
ET(rv);
}
+struct rumpuser_mtx {
+ pthread_mutex_t pthmtx;
+ struct lwp *owner;
+ int flags;
+};
+
void
rumpuser_mutex_init(struct rumpuser_mtx **mtx, int flags)
{
@@ -274,6 +222,48 @@
*lp = mtx->owner;
}
+/*
+ * rwlocks
+ */
+
+struct rumpuser_rw {
+ pthread_rwlock_t pthrw;
+ pthread_spinlock_t spin;
+ int readers;
+ struct lwp *writer;
+};
+
+#define RURW_AMWRITER(rw) (rw->writer == rumpuser_curlwp() \
+ && rw->readers == -1)
+#define RURW_HASREAD(rw) (rw->readers > 0)
+
+#define RURW_SETWRITE(rw) \
+do { \
+ assert(rw->readers == 0); \
+ rw->writer = rumpuser_curlwp(); \
+ rw->readers = -1; \
+} while (/*CONSTCOND*/0)
+#define RURW_CLRWRITE(rw) \
+do { \
+ assert(RURW_AMWRITER(rw)); \
+ rw->readers = 0; \
+ rw->writer = NULL; \
+} while (/*CONSTCOND*/0)
+#define RURW_INCREAD(rw) \
+do { \
+ pthread_spin_lock(&rw->spin); \
+ assert(rw->readers >= 0); \
+ ++(rw)->readers; \
+ pthread_spin_unlock(&rw->spin); \
+} while (/*CONSTCOND*/0)
+#define RURW_DECREAD(rw) \
+do { \
+ pthread_spin_lock(&rw->spin); \
+ assert(rw->readers > 0); \
+ --(rw)->readers; \
+ pthread_spin_unlock(&rw->spin); \
+} while (/*CONSTCOND*/0)
+
void
rumpuser_rw_init(struct rumpuser_rw **rw)
{
@@ -386,6 +376,15 @@
}
}
+/*
+ * condvar
+ */
+
+struct rumpuser_cv {
+ pthread_cond_t pthcv;
+ int nwaiters;
+};
+
void
rumpuser_cv_init(struct rumpuser_cv **cv)
{
@@ -522,6 +521,8 @@
* curlwp
*/
+static pthread_key_t curlwpkey;
+
/*
* the if0'd curlwp implementation is not used by this hypervisor,
* but serves as test code to check that the intended usage works.
@@ -625,3 +626,10 @@
return pthread_getspecific(curlwpkey);
}
#endif
+
+
+void
+rumpuser__thrinit(void)
+{
+ pthread_key_create(&curlwpkey, NULL);
+}
Home |
Main Index |
Thread Index |
Old Index