The always-worth-reading Raymond Chen happens to be talking about Thread-Local Storage on Windows this week. In his essay, he references Ken Johnson's eight-part description of how Thread-Local Storage works, under the covers, using support from compiler, linker/loader, and the operating system, a description which is so good that it's worth linking to all of Johnson's articles right now:
There is no such thing as "too much information" when it comes to topics like "how does the magic behind __declspec(thread) actually work?" Johnson's in-depth explanations do the world a tremendous favor. Read; learn; enjoy!
- Thread Local Storage, part 1: Overview
- Thread Local Storage, part 2: Explicit TLS
- Thread Local Storage, part 3: Compiler and linker support for implicit TLS
- Thread Local Storage, part 4: Accessing __declspec(thread) data
- Thread Local Storage, part 5: Loader support for __declspec(thread) variables (process initialization time)
- Thread Local Storage, part 6: Design problems with the Windows Server 2003 (and earlier) approach to implicit TLS
- Thread Local Storage, part 7: Windows Vista support for __declspec(thread) in demand loaded DLLs
- Thread Local Storage, part 8: Wrap-up
There is no such thing as "too much information" when it comes to topics like "how does the magic behind __declspec(thread) actually work?" Johnson's in-depth explanations do the world a tremendous favor. Read; learn; enjoy!