aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/_mutex.h
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2003-11-11 22:07:29 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2003-11-11 22:07:29 +0000
commit961a7b244dbfc467c112b7a594825da8c0a41acf (patch)
tree36b8de06ad4037f5e371960980d0d088dfd98235 /sys/sys/_mutex.h
parenta6cb9d8e99d421c105802a0609233a8b013d62fb (diff)
downloadsrc-961a7b244dbfc467c112b7a594825da8c0a41acf.tar.gz
src-961a7b244dbfc467c112b7a594825da8c0a41acf.zip
Add an implementation of turnstiles and change the sleep mutex code to use
turnstiles to implement blocking isntead of implementing a thread queue directly. These turnstiles are somewhat similar to those used in Solaris 7 as described in Solaris Internals but are also different. Turnstiles do not come out of a fixed-sized pool. Rather, each thread is assigned a turnstile when it is created that it frees when it is destroyed. When a thread blocks on a lock, it donates its turnstile to that lock to serve as queue of blocked threads. The queue associated with a given lock is found by a lookup in a simple hash table. The turnstile itself is protected by a lock associated with its entry in the hash table. This means that sched_lock is no longer needed to contest on a mutex. Instead, sched_lock is only used when manipulating run queues or thread priorities. Turnstiles also implement priority propagation inherently. Currently turnstiles only support mutexes. Eventually, however, turnstiles may grow two queue's to support a non-sleepable reader/writer lock implementation. For more details, see the comments in sys/turnstile.h and kern/subr_turnstile.c. The two primary advantages from the turnstile code include: 1) the size of struct mutex shrinks by four pointers as it no longer stores the thread queue linkages directly, and 2) less contention on sched_lock in SMP systems including the ability for multiple CPUs to contend on different locks simultaneously (not that this last detail is necessarily that much of a big win). Note that 1) means that this commit is a kernel ABI breaker, so don't mix old modules with a new kernel and vice versa. Tested on: i386 SMP, sparc64 SMP, alpha SMP
Notes
Notes: svn path=/head/; revision=122514
Diffstat (limited to 'sys/sys/_mutex.h')
-rw-r--r--sys/sys/_mutex.h2
1 files changed, 0 insertions, 2 deletions
diff --git a/sys/sys/_mutex.h b/sys/sys/_mutex.h
index a8cc6db80bb0..0fc0bc823790 100644
--- a/sys/sys/_mutex.h
+++ b/sys/sys/_mutex.h
@@ -38,8 +38,6 @@ struct mtx {
struct lock_object mtx_object; /* Common lock properties. */
volatile uintptr_t mtx_lock; /* Owner and flags. */
volatile u_int mtx_recurse; /* Number of recursive holds. */
- TAILQ_HEAD(, thread) mtx_blocked; /* Threads blocked on us. */
- LIST_ENTRY(mtx) mtx_contested; /* Next contested mtx. */
#ifdef MUTEX_PROFILING
/*