Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Jun 2012 20:01:48 +0000
From:      gmiller@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r238504 - in soc2012/gmiller/locking-head: . lib/libwitness
Message-ID:  <20120628200148.1A23C10657C8@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gmiller
Date: Thu Jun 28 20:01:47 2012
New Revision: 238504
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238504

Log:
   r238485@FreeBSD-dev:  root | 2012-06-20 04:25:19 -0500
   Implement graph node lookup and graph traversal.

Modified:
  soc2012/gmiller/locking-head/   (props changed)
  soc2012/gmiller/locking-head/lib/libwitness/graph.c
  soc2012/gmiller/locking-head/lib/libwitness/witness.h

Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/graph.c	Thu Jun 28 20:01:36 2012	(r238503)
+++ soc2012/gmiller/locking-head/lib/libwitness/graph.c	Thu Jun 28 20:01:47 2012	(r238504)
@@ -29,9 +29,56 @@
 
 struct graph_node *root = NULL;
 
+static struct graph_node *
+scan_graph(struct graph_node *graph, void *lock)
+{
+	struct graph_node *ret;
+	struct graph_node *child;
+
+	if (graph->lock == lock) {
+		return (graph);
+	}
+
+	child = graph->child;
+	while (child != NULL) {
+		ret = scan_graph(child, lock);
+		if (ret != NULL) {
+			return (ret);
+		}
+
+		child = child->sibling;
+	}
+
+	return (NULL);
+}
+
+static struct graph_node *
+get_node(void *lock)
+{
+	if (root != NULL) {
+		return (scan_graph(root, lock));
+	}
+
+	return (NULL);
+}
+
 int
 insert_edge(struct graph_node *from, struct graph_node *to)
 {
-	from = from; to = to;
-	return 0;
+#if 1
+  // suppress warning
+  get_node(from->lock);
+#endif
+	if (from == to) {
+		return (0);
+	}
+
+	if (scan_graph(to, from->lock) != NULL) {
+		return (-1);
+	}
+
+	/* XXX */
+
+	return (0);
 }
+

Modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/witness.h	Thu Jun 28 20:01:36 2012	(r238503)
+++ soc2012/gmiller/locking-head/lib/libwitness/witness.h	Thu Jun 28 20:01:47 2012	(r238504)
@@ -37,6 +37,9 @@
 };
 
 struct graph_node {
+	void		*lock;
+	struct graph_node *child;
+	struct graph_node *sibling;
 };
 
 extern pthread_mutex_t witness_mtx;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120628200148.1A23C10657C8>