svn commit: r215071 - in user/davidxu/libthr: include lib/libc lib/libc/gen lib/libc/stdio lib/libthr lib/libthr/thread

Jilles Tjoelker jilles at stack.nl
Fri Nov 12 13:19:43 UTC 2010


On Wed, Nov 10, 2010 at 01:27:48AM +0000, David Xu wrote:
> Author: davidxu
> Date: Wed Nov 10 01:27:48 2010
> New Revision: 215071
> URL: http://svn.freebsd.org/changeset/base/215071

> Log:
>   Convert pthread_mutex_t and pthread_cond_t to structure based instead of
>   pointer type, this allows us to support process-shared.

Very nice.

Apart from supporting process-shared, this also helps avoid the "array
of synchronization objects" anti-pattern (false sharing). It is not so
bad for the old struct pthread_mutex which is 64 bytes on i386, but in
other cases one cache line may contain parts of multiple unrelated
synchronization objects.

In this regard, it would be better for stdio to allocate
  struct { FILE file; pthread_mutex_t lock; }
rather than separate FILEs and locks.

Like the sem_t change, this changes the ABI in a way symver can only
partially deal with (think plugins with pthread_mutex_t in struct in
public header file). However, I think the change should be made
regardless.

-- 
Jilles Tjoelker


More information about the svn-src-user mailing list