diff options
author | davidxu <davidxu@FreeBSD.org> | 2006-08-28 04:52:50 +0000 |
---|---|---|
committer | davidxu <davidxu@FreeBSD.org> | 2006-08-28 04:52:50 +0000 |
commit | 58fc7458afc685c30fd4c4210ca26cd4792c13ae (patch) | |
tree | aab98ede3e979d8c05c91281262d9ea7b281b2c2 /lib/libthr/thread/thr_private.h | |
parent | 77e7cda2cf95ba670c85a1965aff38d2f83b484a (diff) | |
download | FreeBSD-src-58fc7458afc685c30fd4c4210ca26cd4792c13ae.zip FreeBSD-src-58fc7458afc685c30fd4c4210ca26cd4792c13ae.tar.gz |
Use umutex APIs to implement pthread_mutex, member pp_mutexq is added
into pthread structure to keep track of locked PTHREAD_PRIO_PROTECT mutex,
no real mutex code is changed, the mutex locking and unlocking code should
has same performance as before.
Diffstat (limited to 'lib/libthr/thread/thr_private.h')
-rw-r--r-- | lib/libthr/thread/thr_private.h | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/libthr/thread/thr_private.h b/lib/libthr/thread/thr_private.h index 4ec4208..5e00e07 100644 --- a/lib/libthr/thread/thr_private.h +++ b/lib/libthr/thread/thr_private.h @@ -60,6 +60,7 @@ typedef TAILQ_HEAD(pthreadlist, pthread) pthreadlist; typedef TAILQ_HEAD(atfork_head, pthread_atfork) atfork_head; +TAILQ_HEAD(mutex_queue, pthread_mutex); /* Signal to do cancellation */ #define SIGCANCEL 32 @@ -112,22 +113,14 @@ struct pthread_mutex { /* * Lock for accesses to this structure. */ - volatile umtx_t m_lock; + struct umutex m_lock; enum pthread_mutextype m_type; - int m_protocol; struct pthread *m_owner; int m_flags; int m_count; int m_refcount; - - /* - * Used for priority protection, the ceiling priority of - * this mutex. - */ - int m_prio; - /* - * Link for list of all mutexes a thread currently owns. + * Link for all mutexes a thread currently owns. */ TAILQ_ENTRY(pthread_mutex) m_qe; }; @@ -304,6 +297,12 @@ struct pthread_key { }; /* + * lwpid_t is 32bit but kernel thr API exports tid as long type + * in very earily date. + */ +#define TID(thread) ((uint32_t) ((thread)->tid)) + +/* * Thread structure. */ struct pthread { @@ -386,12 +385,6 @@ struct pthread { */ struct pthread *joiner; - /* - * The current thread can belong to a priority mutex queue. - * This is the synchronization queue link. - */ - TAILQ_ENTRY(pthread) sqe; - /* Miscellaneous flags; only set with scheduling lock held. */ int flags; #define THR_FLAGS_PRIVATE 0x0001 @@ -405,8 +398,11 @@ struct pthread { #define TLFLAGS_IN_GCLIST 0x0004 /* thread in gc list */ #define TLFLAGS_DETACHED 0x0008 /* thread is detached */ - /* Queue of currently owned simple type mutexes. */ - TAILQ_HEAD(, pthread_mutex) mutexq; + /* Queue of currently owned NORMAL or PRIO_INHERIT type mutexes. */ + struct mutex_queue mutexq; + + /* Queue of all owned PRIO_PROTECT mutexes. */ + struct mutex_queue pp_mutexq; void *ret; struct pthread_specific_elem *specific; |