LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Stacks in Muti-threaded program (https://www.linuxquestions.org/questions/linux-general-1/stacks-in-muti-threaded-program-452653/)

arunka 06-08-2006 12:56 AM

Stacks in Muti-threaded program
 
Hi all
Since in a muti-threaded program program address space is shared between the threads, will threre be a single stack for all the threads and do i we need to take care of synchronisation while modifying the local variables??

-ARUN KA

paulsm4 06-08-2006 01:20 AM

All threads in a process share the same global address space: true.

But each thread will have it's own stack (each allocated from that process's address space).

So yes, any local variable you allocate from the stack (i.e. any/all "automatic variables") are by definition thread-safe.

You are correct - you do *not* need to synchronize local, "automatic" variables.


All times are GMT -5. The time now is 07:18 PM.