I was working on my OS and I was wondering if the stack in one single process between several threads can be shared or not ??
Can anyone answer this question????
Stacks and multithreading
RE:Stacks and multithreading
The generally accepted definition of a thread has each thread with its own stack, although all other process resources are shared.
Since in most runtimes the stack is used to save the current state of execution, not to mention local variables, having threads share a stack doesn't make a whole lot of sense. If one thread is preempted and another runs and pushes a new return address on the stack, what happends when the original thread resumes?
Since in most runtimes the stack is used to save the current state of execution, not to mention local variables, having threads share a stack doesn't make a whole lot of sense. If one thread is preempted and another runs and pushes a new return address on the stack, what happends when the original thread resumes?