[Xcb] More pthread stubs.

Jamey Sharp jamey at minilop.net
Fri May 7 17:56:14 PDT 2010


On Thu, May 6, 2010 at 5:34 PM, M Joonas Pihlaja
<jpihlaja at cc.helsinki.fi> wrote:
> Wonderful.  I've gone ahead as discussed and added mutex type support
> for mutexattrs, including the troublesome ERRORCHECK mutex type.  The
> work is in the mutexattr branch here:
>
> http://cgit.freedesktop.org/~joonas/pthread-stubs/log/?h=mutexattr

Sigh. I wish creating an error-checking mutex was done with a separate
function so we could make it a link-time error if someone tried it.
Two months ago I apparently wrote, "If somebody asks for an
error-checking mutex, we'd probably better check for self-deadlock. I
guess." but I find I don't like the result. :-( You've written an
elegant and well-researched implementation to meet the letter of the
spec, and I just can't quite convince myself that's the right thing to
do.

For one thing, this can't be compatible with any system's
PTHREAD_MUTEX_INITIALIZER and related definitions. Right? I think that
alone is enough that we shouldn't even try to check the mutex type,
except *maybe* returning an error from
__pthread_mutexattr_settype_stub for the ERRORCHECK type. (But since
we can't tell if they use PTHREAD_MUTEX_ERRORCHECK_NP maybe we
shouldn't even worry about checking in the settype stub.)

This is going to hurt throughput in the common case where a fast mutex
is desired. I find it really hard to justify hurting the common case
to support a rare edge case.

Does the dependency_group bit actually have the effect you want? I'd
worry that the linker might still choose the system's stub where
available even when libpthread-stubs provides one--perhaps dependent
on link order.

In short, I guess I've convinced myself that with the possible
exception of mutexattr_settype, the mutex-related stubs should all
still use the zero-stub. (And mutexattr_gettype shouldn't be provided,
yeah?)

However, in hopes that the world will still have a record of the hard
work you put into this patch later, I'm attaching your patch so it'll
be in the mailing list archives.

Jamey
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mutexattr-stubs.patch
Type: text/x-patch
Size: 7680 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/xcb/attachments/20100507/cf4b05bf/attachment.bin>


More information about the Xcb mailing list