What is __thread tls?

Matthew Dillon dillon at apollo.backplane.com
Mon Mar 14 10:19:16 PST 2005


:
:
:And where is the best place to find definitions of terms I don't know on
:these lists?
:
:Jonathon McKitrick
:--
:My other computer is your Windows box.

    My head?  

    TLS stands for 'thread local storage'.  It is a way of abstracting 
    global variable declarations that you want to be 'per thread' storage
    rather then common storage.

    so, e.g. in a threaded environment, if you declare a global variable:

	int Fubar;

    Then that global variable will represent the same storage across all threads.
    But if you declare it:

	__thread int Fubar;

    Then each thread will be given *different* storage for Fubar.  

    This feature could be used by, well, just about every library.  For example,
    it would allow us to clean up how 'errno' works in a threaded environment.
    It would allow standard libc calls such as ctime() and localtime() work
    properly in a threaded environment, and it would greatly simplify the job
    of writing threaded library code.

					-Matt
					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>





More information about the Kernel mailing list