Re: What is __thread tls?

看板DFBSD_kernel作者時間21年前 (2005/03/15 02:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/8 (看更多)
: : :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@backplane.com>
文章代碼(AID): #12DTYm00 (DFBSD_kernel)
文章代碼(AID): #12DTYm00 (DFBSD_kernel)