Date: Fri, 14 Apr 2006 21:27:27 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95271 for review Message-ID: <200604142127.k3ELRRrh034630@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95271 Change 95271 by jb@jb_freebsd2 on 2006/04/14 21:26:28 Add some experimental (non-POSIX, non-portable) thread functions to check if a mutex or a rwlock is held. Solaris has these in it's non-standard thread implementation and they've implemented DTrace mostly using the non-standard threads, but with some pthreads thrown in... and to make matters worse, even non-POSIX pthread functions. Yuk. Solaris may well be standards compatible from an outside programmer's perspective, but it sure as hell isn't on the inside. Affected files ... .. //depot/projects/dtrace/src/include/pthread_np.h#2 edit .. //depot/projects/dtrace/src/lib/libpthread/pthread.map#2 edit .. //depot/projects/dtrace/src/lib/libpthread/thread/thr_mutex.c#2 edit .. //depot/projects/dtrace/src/lib/libpthread/thread/thr_rwlock.c#2 edit Differences ... ==== //depot/projects/dtrace/src/include/pthread_np.h#2 (text+ko) ==== @@ -49,8 +49,11 @@ int pthread_multi_np(void); int pthread_mutexattr_getkind_np(pthread_mutexattr_t); int pthread_mutexattr_setkind_np(pthread_mutexattr_t *, int); +int pthread_mutex_held_np(pthread_mutex_t *); void pthread_resume_all_np(void); int pthread_resume_np(pthread_t); +int pthread_rwlock_rdheld_np(pthread_rwlock_t *); +int pthread_rwlock_wrheld_np(pthread_rwlock_t *); void pthread_set_name_np(pthread_t, const char *); int pthread_single_np(void); void pthread_suspend_all_np(void); ==== //depot/projects/dtrace/src/lib/libpthread/pthread.map#2 (text+ko) ==== @@ -258,6 +258,7 @@ pthread_multi_np; pthread_mutex_destroy; pthread_mutex_getprioceiling; + pthread_mutex_held_np; pthread_mutex_init; pthread_mutex_lock; pthread_mutex_setprioceiling; @@ -280,6 +281,8 @@ pthread_resume_all_np; pthread_resume_np; pthread_rwlock_destroy; + pthread_rwlock_rdheld_np; + pthread_rwlock_wrheld_np; pthread_rwlock_init; pthread_rwlock_rdlock; pthread_rwlock_timedrdlock; ==== //depot/projects/dtrace/src/lib/libpthread/thread/thr_mutex.c#2 (text+ko) ==== @@ -1582,6 +1582,12 @@ } } +int +pthread_mutex_held_np(pthread_mutex_t *m) +{ + return((*m)->m_owner == _get_curthread()); +} + /* * This is called by the current thread when it wants to back out of a * mutex_lock in order to run a signal handler. ==== //depot/projects/dtrace/src/lib/libpthread/thread/thr_rwlock.c#2 (text+ko) ==== @@ -436,3 +436,15 @@ { return (rwlock_wrlock_common (rwlock, abstime)); } + +int +pthread_rwlock_rdheld_np(pthread_rwlock_t *rwlock) +{ + return((*rwlock)->state > 0); +} + +int +pthread_rwlock_wrheld_np(pthread_rwlock_t *rwlock) +{ + return((*rwlock)->state < 0); +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604142127.k3ELRRrh034630>