cvs commit: src/sys/kern kern_condvar.c kern_mutex.c kern_synch.c
subr_sleepqueue.c subr_turnstile.c src/sys/sys sleepqueue.h
turnstile.h
John Baldwin
jhb at FreeBSD.org
Tue Oct 12 11:36:20 PDT 2004
jhb 2004-10-12 18:36:20 UTC
FreeBSD src repository
Modified files:
sys/kern kern_condvar.c kern_mutex.c kern_synch.c
subr_sleepqueue.c subr_turnstile.c
sys/sys sleepqueue.h turnstile.h
Log:
Refine the turnstile and sleep queue interfaces just a bit:
- Add a new _lock() call to each API that locks the associated chain lock
for a lock_object pointer or wait channel. The _lookup() functions now
require that the chain lock be locked via _lock() when they are called.
- Change sleepq_add(), turnstile_wait() and turnstile_claim() to lookup
the associated queue structure internally via _lookup() rather than
accepting a pointer from the caller. For turnstiles, this means that
the actual lookup of the turnstile in the hash table is only done when
the thread actually blocks rather than being done on each loop iteration
in _mtx_lock_sleep(). For sleep queues, this means that sleepq_lookup()
is no longer used outside of the sleep queue code except to implement an
assertion in cv_destroy().
- Change sleepq_broadcast() and sleepq_signal() to require that the chain
lock is already required. For condition variables, this lets the
cv_broadcast() and cv_signal() functions lock the sleep queue chain lock
while testing the waiters count. This means that the waiters count
internal to condition variables is no longer protected by the interlock
mutex and cv_broadcast() and cv_signal() now no longer require that the
interlock be held when they are called. This lets consumers of condition
variables drop the lock before waking other threads which can result in
fewer context switches.
MFC after: 1 month
Revision Changes Path
1.52 +16 -15 src/sys/kern/kern_condvar.c
1.151 +4 -5 src/sys/kern/kern_mutex.c
1.263 +4 -3 src/sys/kern/kern_synch.c
1.13 +31 -14 src/sys/kern/subr_sleepqueue.c
1.150 +34 -12 src/sys/kern/subr_turnstile.c
1.5 +11 -12 src/sys/sys/sleepqueue.h
1.5 +17 -16 src/sys/sys/turnstile.h
More information about the cvs-src
mailing list