An idea of remove MUTEX_WAKE_ALL
John Baldwin
jhb at freebsd.org
Tue Jan 3 10:06:02 PST 2006
On Sunday 01 January 2006 02:21 am, prime wrote:
> Hi hackers,
> I have an idea about remove the kernel option MUTEX_WAKE_ALL.
> When we unlock the mutex(in _mtx_unlock_sleep),we can directly
> give the lock to the first thread waiting on the turnstile.And a
> thread gets the mutex after he returned from turnstile_wait so he
> can simply jump out the _obtain_lock loop in _mtx_lock_sleep.
> This makes a mutex always be owned by a thread when there are threads
> waiting on the turnstile,so priority inheritance can work now.
> This idea need only a few changes in kern/kern_mutex.c .But when
> NO_ADAPTIVE_MUTEXS not set,it makes threads that spinning on other CPU
> to get the mutex have to spin for a long time,and this makes the short
> term mutex more expensive(maybe should use spin mutex instead).
>
> What do think about the idea? Thanks.
Sun actually found that the performance was better when you did MUTEX_WAKE_ALL
because once you woke up N threads, if they don't all resume at once then
they will acquire the lock in sequence and the lock acquires and releaes will
all be simple ones rather than all being the complicated contested case.
There are more details in _Solaris Internals_.
--
John Baldwin <jhb at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the freebsd-hackers
mailing list