Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 06-08-2006, 01:56 AM   #1
Registered: Mar 2005
Posts: 60

Rep: Reputation: 15
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??

Old 06-08-2006, 02:20 AM   #2
LQ Guru
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
question?, X + muti monitors + multi compuers over network SciYro Linux - General 2 06-16-2005 10:26 PM
Stop java program(threaded program..should end cleanly) rmanocha Programming 4 11-09-2004 10:36 AM
8 kb stacks Jose Muņiz Linux - General 1 05-10-2004 05:36 PM
What is the difference between a "Threaded version" and "Non Threaded" packages? davidas Linux - Newbie 1 04-05-2004 07:23 PM
Cant Compile(link) a C Threaded program tristan_vdv Programming 2 05-30-2002 06:16 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:26 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration