Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 12 Nov 2010 10:17:28 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        Jilles Tjoelker <jilles@stack.nl>
Cc:        src-committers@freebsd.org, David Xu <davidxu@freebsd.org>, svn-src-user@freebsd.org
Subject:   Re: svn commit: r215071 - in user/davidxu/libthr: include lib/libc lib/libc/gen lib/libc/stdio lib/libthr lib/libthr/thread
Message-ID:  <201011121017.28819.jhb@freebsd.org>
In-Reply-To: <20101112131941.GA57806@stack.nl>
References:  <201011100127.oAA1Rmrh069656@svn.freebsd.org> <20101112131941.GA57806@stack.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Friday, November 12, 2010 8:19:42 am Jilles Tjoelker wrote:
> 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.

Note that stdio already does this.  It currently expands 'pthread_mutex_t'
to avoid namespace pollution in <stdio.h>, but it does embed the 
pthread_mutex_t in FILE directly already.  This does mean that changing 
pthread_mutex_t will change the ABI of FILE, but I think it is not an 
incompatible change as it should not affect the "public" fields accessed via
macros.

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201011121017.28819.jhb>