Commit Graph

14 Commits

Author SHA1 Message Date
nathanw baa073280b Separately report unlocking an unlocked mutex and unlocking a mutex
owned by another thread.
2003-05-16 21:28:26 +00:00
nathanw 3f6de8d84a Use pthread__error() instead of pthread__abort(). 2003-04-23 19:36:12 +00:00
nathanw b7ac97b866 More agressive assertions. Change a number of detected conditions, which
officially have undefined behavior, from returning an error code to raising
an assertion failure.
Also, don't bother to explicitly test for (illegal) null pointers and return
an error; they'll bomb out soon enough.
2003-04-18 21:36:38 +00:00
nathanw a74799949a pthread_mutex_trylock(): It's not an error to call trylock() on a
mutex already locked by the calling thread, even for non-recursive
mutexes.
2003-04-16 18:59:12 +00:00
nathanw 008033bb65 When a thread sleeps on a mutex or cv, have it put itself on the
front of the sleep queue rather than the back. This is more
cache-friendly behavior and within the (lack of) constraints on wakeup
ordering imposed on equal-priority threads.
2003-04-16 18:30:43 +00:00
lukem f043c0fb57 add __RCSID() 2003-03-08 08:03:34 +00:00
nathanw 515d60d00c Remove unnecessary inclusion of <assert.h>. 2003-02-15 00:52:18 +00:00
nathanw 6cca91fc86 Mutex tuneup.
* Use a double-checked locking technique to avoid taking
   the interlock in pthread_mutex_unlock().

 * In pthread_mutex_lock() and pthread_mutex_trylock(), only store the
   stack pointer, not the thread ID, in ptm_owner. Do the translation
   to a thread ID in the slow-lock, errorcheck, and recursive mutex
   cases rather than in the common path.

 * Juggle where pthread__self() is called, to move it out of the fast path.

Overall, this means that neither pthread_self() nor
pthread_spin[un]lock() are used in the course of locking and unlocking
an uncontested mutex. Speeds up the fast path by 40-50%, and
eliminates about 98% of spinlocks used by a couple of large threaded
applications.

(Still a GET_MUTEX_PRIVATE() in the fast path... perhaps the type
should be in the main body of the mutex).
2003-01-31 02:55:00 +00:00
nathanw 6505a5330c Add debug counters for mutex and condvar operations. 2003-01-27 21:01:00 +00:00
scw 5f7bdeae84 Need to include <string.h> for memcmp() prototype. 2003-01-22 13:49:14 +00:00
thorpej 096005bf70 Fix typo. 2003-01-19 21:42:09 +00:00
thorpej 592409d356 Add mutexattr_init(), mutexattr_destroy(), and mutexattr_settype() (recursive
mutexes are used by the X libraries).
2003-01-19 20:46:11 +00:00
christos 9631ace572 de-lint 2003-01-18 18:40:52 +00:00
thorpej c62a74e6d5 Merge the nathanw_sa branch. 2003-01-18 10:32:11 +00:00