由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 关于thread的stack
相关主题
请教windows 7 怎么增加堆栈上限static variable存在heap还是stack?
array allocation in chow to know the stack size of your system?
BFS traversal starting from leaf level ???stack/heap corruption
请帮忙看个thread的问题 (with memory dump)问一个private destructor的问题
[合集] 一道M$面试题的解法... (转载)请问一个关于 cost of pointer的问题
heap&stack Linux vs. Windows[合集] What is the inner class wrong
Dynamic programming和backtracking有什么区别吗[合集] 谁给个stack-based allocation 的C++的例子?
how much slower: heap vs stack memory allocation?请问C++ exception后如何清理function stack上的内存资源?
相关话题的讨论汇总
话题: stack话题: thread话题: area话题: 逆序话题: memory
进入Programming版参与讨论
1 (共1页)
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.

1 (共1页)
进入Programming版参与讨论
相关主题
请问C++ exception后如何清理function stack上的内存资源?[合集] 一道M$面试题的解法... (转载)
3 c++ challenge-and-grill questionsheap&stack Linux vs. Windows
为什么会有recursion stack overflow这个问题?Dynamic programming和backtracking有什么区别吗
线程共享变量问题,搞不懂。how much slower: heap vs stack memory allocation?
请教windows 7 怎么增加堆栈上限static variable存在heap还是stack?
array allocation in chow to know the stack size of your system?
BFS traversal starting from leaf level ???stack/heap corruption
请帮忙看个thread的问题 (with memory dump)问一个private destructor的问题
相关话题的讨论汇总
话题: stack话题: thread话题: area话题: 逆序话题: memory