a*****t 发帖数: 30 | 1 cs:app上这么描述的:
The memory model for the separate thread stacks is not as clean. These
stacks are contained in the stack area of the virtual address space, and are
usually accessed independently by their respective threads.
按这个说法,thread的stack是分配在 virtual memory的stack区域。
但是这样如何管理呢? 当一个thread退出后, 如果释放它的thread堆栈, 是不是就
在全局的堆栈区域里产生了一片空白区域? (因为线程的退出肯定不是按照他们建立顺序的逆序进行的。)
这点让我很不理解。
有没有什么资料能详细讲这些的? 多谢 |
l********g 发帖数: 134 | 2 what's wrong with it?
usually the stack range allocated to a thread is pretty big.
are
立顺序的逆序进行的。)
【在 a*****t 的大作中提到】 : cs:app上这么描述的: : The memory model for the separate thread stacks is not as clean. These : stacks are contained in the stack area of the virtual address space, and are : usually accessed independently by their respective threads. : 按这个说法,thread的stack是分配在 virtual memory的stack区域。 : 但是这样如何管理呢? 当一个thread退出后, 如果释放它的thread堆栈, 是不是就 : 在全局的堆栈区域里产生了一片空白区域? (因为线程的退出肯定不是按照他们建立顺序的逆序进行的。) : 这点让我很不理解。 : 有没有什么资料能详细讲这些的? 多谢
|
m*****e 发帖数: 4193 | 3 The description is not entirely accurate.
For Linux pthread/x86, each thread allocates a block of virtual memory for
its stack use. It's not the typical "stack area" in the sense of memory
management.
are
立顺序的逆序进行的。)
【在 a*****t 的大作中提到】 : cs:app上这么描述的: : The memory model for the separate thread stacks is not as clean. These : stacks are contained in the stack area of the virtual address space, and are : usually accessed independently by their respective threads. : 按这个说法,thread的stack是分配在 virtual memory的stack区域。 : 但是这样如何管理呢? 当一个thread退出后, 如果释放它的thread堆栈, 是不是就 : 在全局的堆栈区域里产生了一片空白区域? (因为线程的退出肯定不是按照他们建立顺序的逆序进行的。) : 这点让我很不理解。 : 有没有什么资料能详细讲这些的? 多谢
|
a*****t 发帖数: 30 | 4 Thanks a lot. At first I thought that the "stack area" was the stack of the
process. And each thread use a part of the "stack area" as its local stack.
And this made me very confused.
I think it makes more sense that each thread is allocated with a signle "
stack area", which probably comes from the heap of the process. Am I right? |
m*****e 发帖数: 4193 | 5 Not heap, but a separately mapped area.
the
stack.
【在 a*****t 的大作中提到】 : Thanks a lot. At first I thought that the "stack area" was the stack of the : process. And each thread use a part of the "stack area" as its local stack. : And this made me very confused. : I think it makes more sense that each thread is allocated with a signle " : stack area", which probably comes from the heap of the process. Am I right?
|
m****t 发帖数: 37 | 6 看图
https://computing.llnl.gov/tutorials/pthreads/images/process.gif
https://computing.llnl.gov/tutorials/pthreads/images/thread.gif
are
立顺序的逆序进行的。)
【在 a*****t 的大作中提到】 : cs:app上这么描述的: : The memory model for the separate thread stacks is not as clean. These : stacks are contained in the stack area of the virtual address space, and are : usually accessed independently by their respective threads. : 按这个说法,thread的stack是分配在 virtual memory的stack区域。 : 但是这样如何管理呢? 当一个thread退出后, 如果释放它的thread堆栈, 是不是就 : 在全局的堆栈区域里产生了一片空白区域? (因为线程的退出肯定不是按照他们建立顺序的逆序进行的。) : 这点让我很不理解。 : 有没有什么资料能详细讲这些的? 多谢
|
a*****t 发帖数: 30 | 7 Yes, by pthread_attr_setstacksize/ pthread_attr_setstackaddr,
the stack can be set up freely, not the heap.
【在 m*****e 的大作中提到】 : Not heap, but a separately mapped area. : : the : stack.
|