Training
×

Thread Local Storage

Thread Local Storage (TLS) is a Windows feature that comes in quite handy for DLLs. INtime provides the same functionality for RSLs.
If an RSL needs data that is specific for a process, all it needs to do is to export one or more variables. But what if it needs data for each thread? TLS provides the answer. This is how it works.
TLS is a table of 64 32-bit entries allocated for each thread in a process. An RSL allocates an index in this table for use in the current process. For every new thread, the TLS value with that index is initialized. At thread detach, the TSL value with that index is released (if any dynamic memory had been allocated).