I'm playing around with pthreads, now it seems to me, that when i call pthread_create from a thread that was previously spawned with pthread_create, the stack for the new pthread will be allocated on the stack of the father thread. In the main-thread, this would not be a problem, because the main thread's stack can still grow, as the MMU will allocate and map new memory for it when neccessary, but a pthread has a fixed stacksize. So when i create a pthread from a pthread, I have to make sure that the father-pthread's stacksize (and guardsize) is large enough to hold the child pthread's stack (plus guardpages).
Is that assumption correct? I haven't been able to find any documentation on this.
A parent-thread created using pthread_create() may create another child-thread using pthread_create().
If the the child's stack would live on the parent's stack then the child's stack would become invalid as soon as the parent ends, and the child couldn't live on.
The latter is not the case.
From this one can conclude the child's stack does not live on the parent's stack.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With