Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2003 13:43:14 -0700
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        threads@FreeBSD.org
Subject:   TLS: defining the problem space
Message-ID:  <20030620204314.GA19111@dhcp01.pn.xcllnt.net>

next in thread | raw e-mail | index | archive | help
Gang,

After the first round of discussions, it seems beneficial to draw
the problem space. As far as I can see it, we have a 3-dimensional
problem space:

X.  complete vs shared executable. Complete means static, but is
    a term used in certain environments. The advantage of complete
    in this context is that it allows us to use static to mean
    something else. The big difference between complete and shared
    is the presence (or absence) of RTLD.

Y.  static vs dynamic. This of course refers to the TLS model in use.
    A process can have both models in use at the same time!, but only
    if the process belongs to a complete binary (ie: you cannot have
    the static TLS model in shared executables, but you can have the
    dynamic TLS model in complete executables. The big difference
    between static and dynamic is the use of __tls_get_addr() to get
    the virtual address of a thread local variable (or not).

Z.  with pthread vs without pthread. This means whether a threads
    library (libc_r, libthr or libkse) is present and/or in use. The
    existence of the __thread keyword does not imply or mean that
    the process will be multi-threaded. This means that we have to
    deal with TLS access outside the context of RTLD or pthread. The
    big difference between pthread and without pthread is the ability
    to actually have multiple threads.

Examples of problems we need to solve are:
o  In a complete executable, without pthread and using dynamic TLS,
   what defines __tls_get_addr() and how is it defined?
o  In a complete executable, without pthread and using static TLS,
   where is the thread pointer initialized?

Examples of answers we have, but may need to revise:
o  In a complete executable, with pthread and using static TLS,
   the thread pointer is defined by the pthread library.
o  In a complete executable, with pthread and using dynamic TLS,
   __tls_get_addr() is defined by the pthread library.

The intend of the posting is to come up with all questions and make
sure we have them all answered before we do anything else. Note that
answers may have tricky consequences, such as:

If pthread defines __tls_get_addr() in complete executables and RTLD
defines __tls_get_addr() in shared executables, we have duplicate
definitions for shared executables, with pthread (using dynamic TLS).
Which takes precedence? [answer: RTLD]

It probably helps to have a authoritative list of questions and answers.
I can probably create a trivial page somewhere where we list it...

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel@xcllnt.net



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030620204314.GA19111>