Subject: Re: Thread implementation with TLS support?
To: None <tech-kern@netbsd.org>
From: Matthew Mondor <mm_lists@pulsar-zone.net>
List: tech-kern
Date: 03/11/2005 16:01:17
On Fri, 11 Mar 2005 01:45:31 +0100
"Anselm R. Garbe" <garbeam@gmail.com> wrote:
> Hi there,
>
> a) I want to get plan9ports [1] running on NetBSD 2.0.1. But for this
> purpose I need TLS (Thread Local Storage) support in NetBSD-2. I know
> that FreeBSD-5 has those, also Darwin, but I ask if NetBSD-2 has also
> TLS support in its thread implementation?
>
> b) If a) is the case, does the NetBSD linker support the gcc feature
> (since gcc 3.3) of a __thread modifier to the declaration of global
> and static variables? This extra modifier means that the variable's
> value is thread-local; one thread changing its value will not affect
> the value of the variable in any other thread.
NetBSD libpthread however does support POSIX standard
pthread_key_create(3), pthread_key_delete(3), pthread_setspecific(3) and
pthread_getspecific(3), this latter being a cheap and fast call, and
should be the best bet to use for portability. Unfortunately, if the
application you're trying to port does not use these, it'll require
modifications at current time.
Matt