Re: Stack Size of a thread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



--On Sunday, October 19, 2003 12:35 PM +0200 sting sting <zstingx@xxxxxxxxxxx> wrote:

As I know there is a default stack size for a pthread; but it grows and
shrinks during run time.
can I know the size of this stack during run time ?

I don't know about Linux, but under another OS (OS/2) the stack address space is allocated (ie. maximum size set but physical pages not assigned) when the thread is created. A "guard" page is created at the top of the stack, which initially is the first page. This is a hardware thing that causes a special page fault when an access is made, causing the kernel to assign a real page and make the next page a guard page. Eventually all the address space is used up and the stack can't grow any more. So the question becomes how to know how many actual pages are assigned.


If you just want to know how much stack is in use, you can at least read the stack pointer of another thread using debugger API's. (Reading a thread's own stack pointer is trivial.) I haven't done this but that's where I'd start.



_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux