Stacks and multithreading

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Morpheus

Stacks and multithreading

Post by Morpheus »

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????
bregmasoft

RE:Stacks and multithreading

Post by bregmasoft »

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?
Post Reply