DragonFly BSD
DragonFly kernel List (threaded) for 2005-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: What is __thread tls?

From: Matthew Dillon <dillon@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 14 Mar 2005 10:17:53 -0800 (PST)

: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.

					Matthew Dillon 

[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]