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: Stefan Hajnoczi
Subject: Re: [Qemu-devel] [PATCH] qemu-thread: add TLS wrappers
Date: Wed, 17 Aug 2011 17:51:06 +0100

On Tue, Aug 16, 2011 at 7:51 PM, Paolo Bonzini <address@hidden> wrote:
> Win32 emulated TLS is slow and is not available on all versions of GCC.
> Actually, Win32 does have support for decent TLS, only GCC does not map
> __thread to it.  The good news is, it's perfectly possible to declare
> TLS variables with simple C code!
>
> This patch adds wrappers to qemu-thread that will use __thread on POSIX
> systems, and the .tls segment on Windows.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
>        It does kinda uglify the declarations, but not too much IMO.
>        Do we want to go this way?  It will certainly limit the number
>        of bug reports we get.
>
>  coroutine-win32.c   |    7 +++++--
>  qemu-thread-posix.h |    4 ++++
>  qemu-thread-win32.c |   17 +++++++++++++++++
>  qemu-thread-win32.h |   40 +++++++++++++++++++++++++++++++++++++++-
>  qemu-thread.h       |    2 ++
>  5 files changed, 67 insertions(+), 3 deletions(-)

Hmm...this is pretty ugly low-level stuff.  glib provides portable TLS
although I have found __thread significantly faster on Linux.

I think our options are:
1. Use __thread and require recent gcc versions on Windows.  Not as
fast as native Windows TLS.
2. Implement our own TLS abstraction to use native TLS on each platform.
3. Use glib TLS (GStaticPrivate).  It's slower than __thread on Linux
but seems portable.

Options 1 and 3 seem better because they do not involve us
reimplementing yet more platform abstractions.  Option 1 would be
nicest.

Do you know which Windows gcc versions support __thread and if it
would be reasonable to require those versions?

Stefan



reply via email to

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