[PATCH xserver 4/8] Create a threaded mechanism for input [v3]
Mark Kettenis
mark.kettenis at xs4all.nl
Fri Dec 11 04:28:37 PST 2015
> From: Keith Packard <keithp at keithp.com>
> Date: Thu, 10 Dec 2015 07:18:23 -0800
>
> Mark Kettenis <mark.kettenis at xs4all.nl> writes:
>
> > Ugh. Exporting global variables as part of the ABI is generally not
> > such a good idea. Perhaps it is better to use functions to acquire
> > and release the input mutex instead?
>
> Yeah, it's not a performance sensitive operation, so hiding the globals
> in a function is a good idea. I'll leave the stub versions as static
> inline so I don't have to move them to the new file (inputthread.c)
> later, just redefine them in the header file.
>
> > Also, using TLS (i.e. __thread variables) isn't portable. That
> > mechanism certainly isn't supported by all platforms supported by
> > Xorg.
>
> I can add some autoconf magic to autodetect whether this is supported
> and disable threaded input where it isn't.
Is that really necessary? If I understand the code correctly, you're
using the __thread variable just to implement a recursive mutex.
There are ways to do that without using a per-thread counter, which
would avoid using the non-portable __thread storage class.
However, is there a reason why you didn't use the
PTHREAD_MUTEX_RECURSIVE mtex type that is standardized by POSIX?
More information about the xorg-devel
mailing list