socsvn commit: r236445 - in soc2012/gmiller/locking-head: include
lib/libthr/thread
gmiller at FreeBSD.org
gmiller at FreeBSD.org
Sat May 26 06:16:14 UTC 2012
Author: gmiller
Date: Sat May 26 06:16:12 2012
New Revision: 236445
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=236445
Log:
Macroize pthread_mutex_lock() in order to add the file and line parameters
that identify the acquisition point for the lock.
Modified:
soc2012/gmiller/locking-head/include/pthread.h
soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c
Modified: soc2012/gmiller/locking-head/include/pthread.h
==============================================================================
--- soc2012/gmiller/locking-head/include/pthread.h Sat May 26 05:29:53 2012 (r236444)
+++ soc2012/gmiller/locking-head/include/pthread.h Sat May 26 06:16:12 2012 (r236445)
@@ -179,6 +179,12 @@
__pthread_cleanup_pop_imp(execute); \
}
+#ifdef LOCK_PROFILING
+#define _PTHREAD_PROFILE_PARMS , const char *, int
+#else
+#define _PTHREAD_PROFILE_PARMS /* */
+#endif
+
int pthread_condattr_destroy(pthread_condattr_t *);
int pthread_condattr_getclock(const pthread_condattr_t *,
clockid_t *);
@@ -215,7 +221,7 @@
int pthread_mutex_destroy(pthread_mutex_t *);
int pthread_mutex_init(pthread_mutex_t *,
const pthread_mutexattr_t *);
-int pthread_mutex_lock(pthread_mutex_t *);
+int pthread_mutex_lock(pthread_mutex_t * _PTHREAD_PROFILE_PARMS);
int pthread_mutex_trylock(pthread_mutex_t *);
int pthread_mutex_timedlock(pthread_mutex_t *,
const struct timespec *);
@@ -294,4 +300,16 @@
void __pthread_cleanup_pop_imp(int);
__END_DECLS
+#ifdef LOCK_PROFILING
+
+#ifndef pthread_mutex_lock
+#define pthread_mutex_lock(m) \
+ pthread_mutex_lock (m, __FILE__, __LINE__)
+#endif
+
+#define _pthread_mutex_lock(m) \
+ _pthread_mutex_lock (m, __FILE__, __LINE__)
+
+#endif
+
#endif
Modified: soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c
==============================================================================
--- soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c Sat May 26 05:29:53 2012 (r236444)
+++ soc2012/gmiller/locking-head/lib/libthr/thread/thr_mutex.c Sat May 26 06:16:12 2012 (r236445)
@@ -71,13 +71,19 @@
*/
#define MUTEX_ADAPTIVE_SPINS 2000
+#ifdef LOCK_PROFILING
+#define _PROFILE_PARMS , const char *file, int line
+#else
+#define _PROFILE_PARMS /* */
+#endif
+
/*
* Prototypes
*/
int __pthread_mutex_init(pthread_mutex_t *mutex,
const pthread_mutexattr_t *mutex_attr);
int __pthread_mutex_trylock(pthread_mutex_t *mutex);
-int __pthread_mutex_lock(pthread_mutex_t *mutex);
+int __pthread_mutex_lock(pthread_mutex_t *mutex _PROFILE_PARMS);
int __pthread_mutex_timedlock(pthread_mutex_t *mutex,
const struct timespec *abstime);
int _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
@@ -354,6 +360,10 @@
if (m->m_owner == curthread)
return mutex_self_lock(m, abstime);
+#if 0
+ lock_profile_obtain_lock_success();
+#endif
+
id = TID(curthread);
/*
* For adaptive mutexes, spin for a bit in the expectation
@@ -432,7 +442,7 @@
}
int
-__pthread_mutex_lock(pthread_mutex_t *mutex)
+__pthread_mutex_lock(pthread_mutex_t *mutex _PROFILE_PARMS)
{
struct pthread_mutex *m;
More information about the svn-soc-all
mailing list