Is there a known size limit of the thread local storage in a prevalent modern OS?

妖精的绣舞 提交于 2021-02-07 14:39:27

问题


When I use thread_local, _Thread_local, __thread, or __declspec(thread), the compiler seems to allocate a thread local storage upon thread creation and store the address in the fs or gs register in an x86 derived system.

In this context, is there something like 'thread local storage overflow'?


回答1:


There are limits. Each system will be different, but on Windows, there is a limited data section which is mapped thread specifically. The size of this section is limited.

Older versions of windows used this directly, and would fail when new items were created.

Last time I checked on Windows 7+, this had gone (OS uses 1 slot for the whole DLL - as a redirection to a thread local map), but there was a different limitation, which limited the number of unique slots available. Each DLL loaded used a slot, and thus there was a limit on the number of DLLs which could use thread local storage.

See also wikipedia : thread local storage



来源:https://stackoverflow.com/questions/32310208/is-there-a-known-size-limit-of-the-thread-local-storage-in-a-prevalent-modern-os

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!