externs and thread local storage

Seongbae Park seongbae.park@gmail.com
Mon Jul 3 20:57:00 GMT 2006


On 7/3/06, Gary Funck <gary@intrepid.com> wrote:
>
> Seongbae Park wrote:
> > As I said, you're welcome to implement a new option
> > (either a runtime option or a compile time configuration option)
> > that will allow mixing TLS vs non-TLS.
>
> In a way, we've already done that -- in an experimental dialact of "C"
> called UPC.  When compiled for pthreads, all file scope data not
> declared in a system header file is made thread local, and in fact all
> data referenced through externs is also made thread local.  There is a new
> syntax (a "shared" qualifier) used by the programmer to identify
> objects shared across all threads.  Sounds a little scary, but works
> amazingly well.  Because the tagging of data as __thread local is done
> by the compiler transparently, I tend to think that we probably stress
> the TLS feature more than most.

In UPC, anything that's not TLS (or in UPC term, "private")
is marked explicitly as "shared". So it's NOT trasparent in any sense
of the word.
See, you have two choices - either
1) make every global variable TLS by default and mark only non-TLS (UPC)
or
2) vice versa (C99).

It is not sane to allow TLS/non-TLS attribute changing underneath you
- which is what you proposed.
-- 
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"



More information about the Gcc mailing list