[英]Address Space Layout for a Multithreaded Linux Process
I want to know the full detail of the address space layout of a multithreaded Linux Process for both 64 bit and 32 bit.我想知道 64 位和 32 位的多线程 Linux 进程的地址空间布局的全部细节。 Link to any article that describes it will be appreciated.
链接到任何描述它的文章将不胜感激。 And note that I need to know full details, not just an overview, because I will be directly dealing with it.
请注意,我需要了解全部细节,而不仅仅是概述,因为我将直接处理它。 So I need to know for example, where are the thread stacks located, the heap, thread private data etc...
所以我需要知道例如,线程堆栈位于哪里,堆,线程私有数据等......
Thread stacks are allocated with mmap
at thread start (or even before - you can set the stack space in pthread_attr
s).线程堆栈在线程启动时使用
mmap
分配(甚至更早 - 您可以在pthread_attr
中设置堆栈空间)。 TLS data is stored in the beginning of thread's stack. TLS 数据存储在线程堆栈的开头。 Size of thread's stacks is fixed, typically it is from 2 to 8 MB.
线程堆栈的大小是固定的,通常为 2 到 8 MB。 Stack size of each thread can't be changed while the thread is live.
每个线程的堆栈大小在线程处于活动状态时无法更改。 (First thread - running main - is still uses main stack at the end of address space and this stack may grow and shrink.) Heap and code is shared between all threads.
(第一个线程 - 运行 main - 在地址空间的末尾仍然使用主堆栈,这个堆栈可能会增长和缩小。)堆和代码在所有线程之间共享。 Mutexes can be anywhere in
data
section - it is just a struct.互斥锁可以在
data
部分的任何地方——它只是一个结构。
The mmap of thread's stack is not fixed at any address:线程栈的mmap不固定在任何地址:
mem = mmap (NULL, size, prot,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
PS modern GCC allows threads stack to be unlimited with SplitStacks feature PS 现代 GCC 允许线程堆栈通过SplitStacks功能不受限制
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.