0

I know that Windows and Pthreads have their own TLS API but what I'm asking is how the thread_local keyword is implemented in the C++ compiler (or does it simply call these Windows/Pthreads API?).

I found an answer here about a table of slots in each thread but I still don't really understand it. Can anyone explain?

  • 4
    The details will vary from compiler to compiler and operating system to operating system. – Raymond Chen May 06 '22 at 03:23
  • The compiler has to do extra work in addition to the functions in the OS API's. Neither Windows nor pthreads understand C++ types. Hence, even on the same OS, using the same OS functions, different compilers can make different choices. – MSalters May 06 '22 at 10:45

0 Answers0