Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
1. Assuming a linux-86/32 bit systems, the stack size of a process is 8 Mega Bytes .
if a pthread is being formed within that process, the pthread_attr_getstacksize function throws the stack size as 8MB? how come it is possible, that means all the PROCESS STACK == PTHREAD STACK?
Hi Sir,
Thanks for your answer. Excellent source. [on an other note, i searched it a lot, could not find the exact answer, but your link helped me understand it].
1. to wrap it up, in this case of 3 threads [the ulimit -s is set to 8MB]
./a.out hola salut servus
each of 3 threads [hola, salut, servus] come up with 8 MB of stack and as a whole can i conclude that PROCESS has 8*3=24MB of
stack with it.
In other words, Linux has dynamically extended the stack of process by 3 times [24MB]
Hi Sir,
Thanks for your answer. Excellent source. [on an other note, i searched it a lot, could not find the exact answer, but your link helped me understand it].
1. to wrap it up, in this case of 3 threads [the ulimit -s is set to 8MB]
./a.out hola salut servus
each of 3 threads [hola, salut, servus] come up with 8 MB of stack and as a whole can i conclude that PROCESS has 8*3=24MB of
stack with it.
In other words, Linux has dynamically extended the stack of process by 3 times [24MB]
Hi,
i ran a quick simulation of finding the local variable address in PROCESS at main() and then find the address of local variable inside FIRST created pthread, seriously i dont see any relationship
[root@localhost threads]# ./threadex 1
threadinfo structure size 24
Thread 1: top of stack near 0x7f436d9deee8; argv_string=1
Joined with thread 1; returned value was 1
address of a 0x7fff66a5ffd8
main() function first local variable address: 0x7fff66a5ffd8
FIRST PTHREAD address: 0x7f436d9deee8
there is huge difference between above 2 hex numbers. looks like process has the luxury of all the system memory available as its stack
please let me know if you can reason why is it so?
there is huge difference between above 2 hex numbers. looks like process has the luxury of all the system memory available as its stack
please let me know if you can reason why is it so?
It's virtual memory, in other words the process thinks it has a full 64-bit address space for itself, actually orders of magnitude more than system memory. In reality, only those pages that are in used are mapped to physical memory by the MMU (at least that was state of the art 25 years ago), the others only exist in the process' fantasy.
You are not the first one with questions about process memory layout. An internet search of "linux process memory layout" results in some ten million hits. This is a good example: http://stackoverflow.com/questions/1...eaded-process; I'll leave it up to you to read the 9999999 others
Hi,
i got the answer. I was always thinking from the diagram perspective of stack, heap, bss, data,text. But this post tells that it is obsolete and now all the experiments which i did fall in place w.r.t to thsi post.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.