i am looking through the documentation on thread local storage but i believe its poorly written.
https://learn.microsoft.com/en-us/windows/win32/procthread/thread-local-storage
It seems like the way they write documentations is in a sporadic order, they will provide an event that happens, then the next sentence they will provide information on what needs to happen before this event. And then another event happens, they will explain what needs to happen before this event. But the chain of sequential events is unclear. Often they will provide an object in a sentence, then the next sentence talking about another object while revealing more details about the object before.
But from my understanding, there's a global index where the index has associated data, a thread allocates the index and other threads can then access it. And when threads are created, an array of LPVOID values called the TLS slot are generated. The data associated with the index are then stored in this array.
My confusion lies at the last part, it says the Threads allocate memory blocks, the pointers to these memory blocks are then stored in LPVOID TLS slots. And the pointers to the memory blocks are retrieved from the TLS slots while being stored in the local variable.
My question is exactly what values are stored in the TLS slots, memory address or actual data values? And if memory address pointers, im supposing these addresses are then accessed to get the value stored at the memory block.
Is it also correct that 2 memory spaces are allocated, one for LPVOID array values and there others for memory space blocks for the indexes? It said if using a large number of indexes and LPVOID arrays, its better to allocate a separate memory space to avoid occupying TLS slots, is this what the memory blocks refer to, data is stored in the memory blocks instead and addresses in slots to avoid data overload in the slots?
Reading the documentation is like a puzzle, if anyone can be helpful i would be grateful. Ive shown an image of the illustrated structured they've provided.