Received: from eggs.gnu.org ([140.186.70.92]:49800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qtkus-0006QG-IX for qemu-devel@nongnu.org; Wed, 17 Aug 2011 14:32:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qtkur-0005bA-83 for qemu-devel@nongnu.org; Wed, 17 Aug 2011 14:32:38 -0400 Received: from fe01x03-cgp.akado.ru ([77.232.31.164]:64330 helo=akado.ru) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qtkuq-0005au-VB for qemu-devel@nongnu.org; Wed, 17 Aug 2011 14:32:37 -0400 Date: Wed, 17 Aug 2011 22:32:31 +0400 (MSD) From: malc In-Reply-To: <4E4C026E.4070200@redhat.com> Message-ID: References: <1313520667-26507-1-git-send-email-pbonzini@redhat.com> <4E4BF6D6.5040801@redhat.com> <4E4BFA29.7010703@redhat.com> <4E4BFE4D.2080706@redhat.com> <4E4C026E.4070200@redhat.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH] qemu-thread: add TLS wrappers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Blue Swirl , Stefan Hajnoczi , qemu-devel@nongnu.org On Wed, 17 Aug 2011, Paolo Bonzini wrote: > 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. > thread_local 3.7.2 in n3290.pdf -- mailto:av1474@comtv.ru