Source-Changes-HG archive

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

[src/trunk]: src/lib/librumpuser implement mutex_owner()



details:   https://anonhg.NetBSD.org/src/rev/8b80084bb660
branches:  trunk
changeset: 782424:8b80084bb660
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Nov 02 16:55:02 2012 +0000

description:
implement mutex_owner()

diffstat:

 lib/librumpuser/rumpuser_pth_dummy.c |  20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diffs (73 lines):

diff -r 956199c64cd6 -r 8b80084bb660 lib/librumpuser/rumpuser_pth_dummy.c
--- a/lib/librumpuser/rumpuser_pth_dummy.c      Fri Nov 02 16:47:42 2012 +0000
+++ b/lib/librumpuser/rumpuser_pth_dummy.c      Fri Nov 02 16:55:02 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpuser_pth_dummy.c,v 1.4 2012/11/02 13:31:26 pooka Exp $     */
+/*     $NetBSD: rumpuser_pth_dummy.c,v 1.5 2012/11/02 16:55:02 pooka Exp $     */
 
 /*
  * Copyright (c) 2009 Antti Kantee.  All Rights Reserved.
@@ -29,7 +29,7 @@
 
 #include <sys/cdefs.h>
 #if !defined(lint)
-__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.4 2012/11/02 13:31:26 pooka Exp $");
+__RCSID("$NetBSD: rumpuser_pth_dummy.c,v 1.5 2012/11/02 16:55:02 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/time.h>
@@ -45,10 +45,13 @@
 
 #include "rumpuser_int.h"
 
+static struct lwp *curlwp;
+
 struct rumpuser_cv {};
 
 struct rumpuser_mtx {
        int v;
+       struct lwp *o;
 };
 
 struct rumpuser_rw {
@@ -116,6 +119,7 @@
 {
 
        mtx->v++;
+       mtx->o = curlwp;
 }
 
 int
@@ -130,7 +134,9 @@
 rumpuser_mutex_exit(struct rumpuser_mtx *mtx)
 {
 
-       mtx->v--;
+       assert(mtx->v > 0);
+       if (--mtx->v == 0)
+               mtx->o = NULL;
 }
 
 void
@@ -140,6 +146,13 @@
        free(mtx);
 }
 
+struct lwp *
+rumpuser_mutex_owner(struct rumpuser_mtx *mtx)
+{
+
+       return mtx->o;
+}
+
 void
 rumpuser_rw_init(struct rumpuser_rw **rw)
 {
@@ -271,7 +284,6 @@
  * curlwp
  */
 
-static struct lwp *curlwp;
 void
 rumpuser_set_curlwp(struct lwp *l)
 {



Home | Main Index | Thread Index | Old Index