qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] qemu-thread: add TLS wrappers


From: Paolo Bonzini
Subject: Re: [Qemu-devel] [PATCH] qemu-thread: add TLS wrappers
Date: Wed, 17 Aug 2011 11:03:26 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110707 Thunderbird/5.0

On 08/17/2011 10:51 AM, Blue Swirl wrote:
>  Visual C++ supports __declspec(thread).
>
>  pthread TLS is orders of magnitudes slower than __thread.  __thread in an
>  executable is just as fast as a non-TLS variable access, 2 or 3 machine
>  language instructions at most.
>
>  Some pthread_getspecific implementation do a_linear walk_  of the keys.  In
>  that case it may work to have something like Windows plus a single
>  pthread_getspecific key.  On the other hand, Windows provides very good
>  support for that thanks to its ordered subsections (.tls$something).  It
>  only needs a bit of preprocessor magic.  Thinks such as linker scripts would
>  be way out of scope.

According to this blog, also pthread_getspecific on OSX can amount to
three instructions except on PPC:
http://lifecs.likai.org/2010/05/mac-os-x-thread-local-storage.html

I'll try to work out a DEFINE_TLS/DECLARE_TLS version for pthreads too.

BTW, __thread is in C1X too though I don't remember how they called it.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]