svn commit: r214915 - user/davidxu/libthr/lib/libthr/thread

Jilles Tjoelker jilles at stack.nl
Sat Nov 13 15:10:37 UTC 2010


On Sun, Nov 07, 2010 at 01:49:08PM +0000, David Xu wrote:
> Author: davidxu
> Date: Sun Nov  7 13:49:08 2010
> New Revision: 214915
> URL: http://svn.freebsd.org/changeset/base/214915

> Log:
>   Implement robust mutex, the pthread_mutex locking and
>   unlocking code are reworked to support robust mutex and
>   other mutex must be locked and unlocked by kernel.

The glibc+linux implementation avoids the system call for each robust
mutex lock/unlock by maintaining the list in userland and providing a
pointer to the kernel. Although this is somewhat less reliable in case a
process scribbles over this list, it has better performance.

There are various ways this list could be maintained, but the glibc way
uses an "in progress" field per thread and a linked list using a field
in the pthread_mutex_t, so if we want that we should make sure we have
the space in the pthread_mutex_t. Alternatively, a simple array could be
used if the number of owned robust mutexes can be limited to a fairly
low value.

Solaris robust mutexes used to work by entering the kernel for every
lock/unlock, but no longer, see
http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id=6296770
Someone complained about that implementation being too slow.

-- 
Jilles Tjoelker


More information about the svn-src-user mailing list