LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 06-08-2006, 12:56 AM   #1
arunka
Member
 
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??

-ARUN KA
 
Old 06-08-2006, 01:20 AM   #2
paulsm4
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.
 
  


Reply


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 09:26 PM
Stop java program(threaded program..should end cleanly) rmanocha Programming 4 11-09-2004 09:36 AM
8 kb stacks Jose Muņiz Linux - General 1 05-10-2004 04:36 PM
What is the difference between a "Threaded version" and "Non Threaded" packages? davidas Linux - Newbie 1 04-05-2004 06:23 PM
Cant Compile(link) a C Threaded program tristan_vdv Programming 2 05-30-2002 05:16 AM


All times are GMT -5. The time now is 09:28 PM.

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