From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] __thread instead of pthread_get/setspecific
Date: Tue, 14 Oct 2008 14:53:11 +0200 [thread overview]
Message-ID: <48F49637.2030000@domain.hid> (raw)
In-Reply-To: <48F49540.3060507@domain.hid>
Jan Kiszka wrote:
> Gilles Chanteperdrix wrote:
>> Jan Kiszka wrote:
>>> Gilles Chanteperdrix wrote:
>>>> Jan Kiszka wrote:
>>>>> It will always remain orders of magnitude heavier than __thread
>>>>> variables which are a) inlined and b) should only need two memory
>>>>> accesses at worst. Moreover, it is clearly the future, while the
>>>>> importance of pthread_getspecific will decrease over the time. The
>>>>> __thread storage class is C99 standard (though its implementation
>>>>> remains a separate topic).
>>>> You are exagerating a bit: pthread_getspecific is pretty efficient
>>>> already (from the few things that I have timed on ARM, it is the only
>>>> one which takes under the microsecond). That you will gain something
>>>> with __thread is not guaranteed by the C99 standard either: in fact the
>>>> implementation could use exactly the same functions.
>>> As long as we do not loose anything (performance or portability),
>> You loose portability. But I agree that we do not care much.
>
> The fallback remains - must remain in order to obtain true optimization
> from the TLS-based version without locking out some corner-case usage.
> Find a proposal below (on top of handle-based xeno_get_current).
>
> We have to set initial-exec as TLS model, otherwise we end up with a
> dynamic lookup similar (maybe still faster, dunno) to the pthread
> service. This model requires start-time linking, will not work with
> dlopen (I strongly assume the linker will bail out). But I consider
> runtime loading of Xenomai libs as a uncommon corner case, and the user
> can still re-enable it via --without-__thread.
glibc has a separate test to know whether the tsl_model attribute is
supported:
if test "$libc_cv_gcc___thread" = yes; then
dnl Check whether the compiler supports the tls_model attribute.
AC_CACHE_CHECK([for tls_model attribute], libc_cv_gcc_tls_model_attr, [dnl
cat > conftest.c <<\EOF
extern __thread int a __attribute__((tls_model ("initial-exec")));
EOF
if AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -S -Werror conftest.c
>&AS_MESSA
GE_LOG_FD]); then
libc_cv_gcc_tls_model_attr=yes
else
libc_cv_gcc_tls_model_attr=no
fi
rm -f conftest*])
if test "$libc_cv_gcc_tls_model_attr" = yes; then
AC_DEFINE(HAVE_TLS_MODEL_ATTRIBUTE)
fi
fi
--
Gilles.
next prev parent reply other threads:[~2008-10-14 12:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-13 21:55 [Xenomai-core] __thread instead of pthread_get/setspecific Jan Kiszka
2008-10-14 8:28 ` Gilles Chanteperdrix
2008-10-14 9:08 ` Jan Kiszka
2008-10-14 9:15 ` Gilles Chanteperdrix
2008-10-14 9:26 ` Jan Kiszka
2008-10-14 9:41 ` Gilles Chanteperdrix
2008-10-14 10:25 ` Jan Kiszka
2008-10-14 12:18 ` Gilles Chanteperdrix
2008-10-14 12:49 ` Jan Kiszka
2008-10-14 12:53 ` Gilles Chanteperdrix [this message]
2008-10-14 12:59 ` Jan Kiszka
2008-10-14 13:02 ` Gilles Chanteperdrix
2008-10-14 13:09 ` Jan Kiszka
2008-10-14 13:22 ` Gilles Chanteperdrix
2008-10-14 13:25 ` Gilles Chanteperdrix
2008-10-14 13:44 ` Jan Kiszka
2008-10-14 14:30 ` Philippe Gerum
2008-10-14 9:58 ` Gilles Chanteperdrix
2008-10-14 10:26 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48F49637.2030000@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=jan.kiszka@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.