skaller <[EMAIL PROTECTED]> writes:

> On Fri, 2007-11-02 at 07:39 -0700, Ian Lance Taylor wrote:
> > skaller <[EMAIL PROTECTED]> writes:
> 
> > In a C executable, TLS requires one extra machine register.  
> 
> You mean gcc?

I don't understand the question.  I mean in a C/C++ executable which
uses TLS.  By TLS I mean __thread, not pthread_get_specific.  In the
GNU/Linux world, TLS conventionally means specifically __thread.


> > I think you need to look at the TLS access code before deciding that
> > it has bad performance. 
> 
> You already said it costs a register? That's a REALLY high cost
> to pay to support badly designed software.

It only costs a register for code which accesses a TLS variable, of
course.


> My argument is basically: there is no need for any such
> feature in a well written program. Each thread already has
> its own local stack. Global variables should not be used
> in the first place (except for signals etc where
> there is no choice).

While global variables are rarely required, there are many cases where
a class is most reasonably implemented using static variables.  For
example, it's very hard to implement malloc without using any static
variables.  And for performance those static variables should be
thread local.

It's just not plausible to say that a C/C++ program should be written
without static variables.  Modern programs are written by different
organizations.  There is no way to pass appropriate state through all
the required interfaces.

Ian

Reply via email to