socsvn commit: r238470 - in soc2012/gmiller/locking-head: .
lib/libwitness
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Thu Jun 28 12:04:20 UTC 2012
Author: gmiller
Date: Thu Jun 28 12:04:18 2012
New Revision: 238470
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=238470
Log:
r238358 at FreeBSD-dev: root | 2012-06-19 22:26:14 -0500
* Add pthread_mutex_unlock() wrapper
* Add calls to add_lock() and remove_lock() in the wrappers
* Add temporary debugging code to make sure the wrapped functions are
tracking the locks held by the current thread correctly.
Modified:
soc2012/gmiller/locking-head/ (props changed)
soc2012/gmiller/locking-head/lib/libwitness/lists.c
soc2012/gmiller/locking-head/lib/libwitness/wrappers.c
Modified: soc2012/gmiller/locking-head/lib/libwitness/lists.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/lists.c Thu Jun 28 11:58:10 2012 (r238469)
+++ soc2012/gmiller/locking-head/lib/libwitness/lists.c Thu Jun 28 12:04:18 2012 (r238470)
@@ -27,6 +27,7 @@
#include <sys/queue.h>
+#include <stdio.h>
#include <stdlib.h>
#include "lists.h"
@@ -34,6 +35,19 @@
_Thread_local SLIST_HEAD(lock_head, lock_entry) lock_head =
SLIST_HEAD_INITIALIZER(lock_head);
+// XXX: temporary debugging code
+static void
+dump_locks(void) {
+ struct lock_entry *entry;
+ int count = 1;
+
+ SLIST_FOREACH(entry, &lock_head, lock_next) {
+ printf("[%d] %p\n", count++, entry->lock);
+ }
+
+ puts("");
+}
+
void
add_lock(void *lock)
{
@@ -43,6 +57,9 @@
entry->lock = lock;
SLIST_INSERT_HEAD(&lock_head, entry, lock_next);
+
+ printf("inserted lock %p\n", lock);
+ dump_locks();
}
void
@@ -58,4 +75,7 @@
break;
}
}
+
+ printf("removed lock %p\n", lock);
+ dump_locks();
}
Modified: soc2012/gmiller/locking-head/lib/libwitness/wrappers.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Thu Jun 28 11:58:10 2012 (r238469)
+++ soc2012/gmiller/locking-head/lib/libwitness/wrappers.c Thu Jun 28 12:04:18 2012 (r238470)
@@ -25,12 +25,38 @@
*
*/
+#include <sys/queue.h>
+
#include <pthread.h>
+#include <stdio.h>
+
+#include "lists.h"
int _pthread_mutex_lock(pthread_mutex_t *mutex);
+int _pthread_mutex_unlock(pthread_mutex_t *mutex);
int
pthread_mutex_lock(pthread_mutex_t *mutex)
{
- return _pthread_mutex_lock(mutex);
+ int ret;
+
+ puts("pthread_mutex_lock()");
+
+ ret = _pthread_mutex_lock(mutex);
+ add_lock(mutex);
+
+ return ret;
+}
+
+int
+pthread_mutex_unlock(pthread_mutex_t *mutex)
+{
+ int ret;
+
+ puts("pthread_mutex_unlock()");
+
+ ret = _pthread_mutex_unlock(mutex);
+ remove_lock(mutex);
+
+ return ret;
}
More information about the svn-soc-all
mailing list