I'am working on a large project with an aim to introduce some multithreading. We started using boost TLS specific storage and I was wondering what is the actual maximum number of TLS indexes supported in Win platform (specifically xp and win7). I checked the implementation and thread_specific_ptr is simply using standard windows TlsGetValue/TlsSetValue API but I'm concerned about what I found here: http://msdn.microsof...9(v=vs.85).aspx
It states that the minimal guaranteed amount of indexes per process is only 64, and maximal number is 1088. We have definitly more then 200 dlls in the project and many of those need a TLS index.
So the question is: how can I check what is the actual number of TLS indexes supported on a specific platform?
The MSDN text is slightly misleading. It's not a number of indexes between 64 and 1,088. It's either 64 or 1,088 indexes for all post Win2k editions of Windows. You get 64 guaranteed as that space is included with the TEB. When you request the 65th index, Windows allocates 1,024 more spaces for the requesting thread only. The additional 1,024 spaces are allocated for other threads when they either call TlsAlloc or TlsSetValue with an index of 64 or greater.
Sp depending on your programs' usage of the process heap, you'll either be able to afford the 4/8K for 1,088 slots for all threads, only some of your threads, or for none of them.