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

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

Log:
   r238483@FreeBSD-dev:  root | 2012-06-20 00:39:33 -0500
   Merge headers into witness.h and add a witness mutex to protect graph
   data structure.

Added:
  soc2012/gmiller/locking-head/lib/libwitness/witness.h
     - copied, changed from r238347, soc2012/gmiller/locking-head/lib/libwitness/lists.h
Deleted:
  soc2012/gmiller/locking-head/lib/libwitness/graph.h
  soc2012/gmiller/locking-head/lib/libwitness/lists.h
Modified:
  soc2012/gmiller/locking-head/   (props changed)
  soc2012/gmiller/locking-head/lib/libwitness/graph.c
  soc2012/gmiller/locking-head/lib/libwitness/lists.c
  soc2012/gmiller/locking-head/lib/libwitness/wrappers.c

Modified: soc2012/gmiller/locking-head/lib/libwitness/graph.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/graph.c	Thu Jun 28 20:00:11 2012	(r238501)
+++ soc2012/gmiller/locking-head/lib/libwitness/graph.c	Thu Jun 28 20:01:25 2012	(r238502)
@@ -25,7 +25,9 @@
  *
  */
 
-#include "graph.h"
+#include "witness.h"
+
+struct graph_node *root = NULL;
 
 int
 insert_edge(struct graph_node *from, struct graph_node *to)

Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.c	Thu Jun 28 20:00:11 2012	(r238501)
+++ soc2012/gmiller/locking-head/lib/libwitness/lists.c	Thu Jun 28 20:01:25 2012	(r238502)
@@ -25,12 +25,7 @@
  *
  */
 
-#include <sys/queue.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "lists.h"
+#include "witness.h"
 
 _Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head =
     SLIST_HEAD_INITIALIZER(lock_head);

Copied and modified: soc2012/gmiller/locking-head/lib/libwitness/witness.h (from r238347, soc2012/gmiller/locking-head/lib/libwitness/lists.h)
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.h	Tue Jun 26 18:55:06 2012	(r238347, copy source)
+++ soc2012/gmiller/locking-head/lib/libwitness/witness.h	Thu Jun 28 20:01:25 2012	(r238502)
@@ -25,10 +25,23 @@
  *
  */
 
+#include <sys/queue.h>
+
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+
 struct lock_entry {
 	SLIST_ENTRY(lock_entry) lock_next;
 	void		*lock;
 };
 
+struct graph_node {
+};
+
+extern pthread_mutex_t witness_mtx;
+
 void	add_lock(void *lock);
 void	remove_lock(void *lock);
+
+int	insert_edge(struct graph_node *from, struct graph_node *to);

Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c	Thu Jun 28 20:00:11 2012	(r238501)
+++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c	Thu Jun 28 20:01:25 2012	(r238502)
@@ -25,23 +25,22 @@
  *
  */
 
-#include <sys/queue.h>
-
-#include <pthread.h>
-#include <stdio.h>
-
-#include "lists.h"
+#include "witness.h"
 
 int	_pthread_mutex_lock(pthread_mutex_t *mutex);
 int	_pthread_mutex_unlock(pthread_mutex_t *mutex);
 
+pthread_mutex_t witness_mtx = PTHREAD_MUTEX_INITIALIZER;
+
 int
 pthread_mutex_lock(pthread_mutex_t *mutex)
 {
 	int ret;
 
 	ret = _pthread_mutex_lock(mutex);
-	add_lock(mutex);
+	if (mutex != &witness_mtx) {
+		add_lock(mutex);
+	}
 
 	return ret;
 }
@@ -52,7 +51,9 @@
 	int ret;
 
 	ret = _pthread_mutex_unlock(mutex);
-	remove_lock(mutex);
+	if (mutex != &witness_mtx) {
+		remove_lock(mutex);
+	}
 
 	return ret;
 }



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