LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-19-2008, 01:10 AM   #1
kumar.anupam
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Rep: Reputation: 0
Post storage of temporary variables in linux while executing c program.


if i am running a C program using gcc compiler in linux, then where does the temporary variables are being stored. and how can we access them?
 
Old 02-19-2008, 07:04 AM   #2
cicorino
Member
 
Registered: May 2006
Location: Italy
Distribution: Slackware, Slackware64
Posts: 31

Rep: Reputation: 16
in short:
1) you use gcc to compile your code into an executable
2) you maybe use a shell to run your executable by a process that comprises a stack area
3) the temporary variables that were declared inside the functions of your code will be created and destroyed inside the process stack by the entry/exit code created at step 1.
 
Old 02-20-2008, 03:36 PM   #3
rednuht
Member
 
Registered: Aug 2005
Posts: 239
Blog Entries: 1

Rep: Reputation: 31
cicorino is correct, please tell us what you are try to do/achieve
 
Old 02-20-2008, 08:52 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,657
Blog Entries: 4

Rep: Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938Reputation: 3938
Every time you "run a program," a process is created ... which represents "an instance of a currently-running program." (That's what a 'process' is.)

Each process "owns" all of the memory that is assigned to it, which it basically uses for one of three purposes:
  1. "The stack," which is where local variables live.
  2. Global-variable storage, which is allocated once when the program starts and remains for the life of the program.
  3. "The heap," which is where dynamically allocated storage blocks (should there be any) come from.
This is true for any modern operating system.

If a process wishes to share memory with any other process, it must allocate a "shared memory segment," which (by suitable operating-system magic...) will be made to appear within the virtual-memory space of each process at the same time. Otherwise, the read/write storage of each process is absolutely isolated from all others, even when the (virtual...) addresses are the same.

Last edited by sundialsvcs; 02-20-2008 at 08:54 PM.
 
Old 02-21-2008, 01:52 AM   #5
kumar.anupam
LQ Newbie
 
Registered: Feb 2008
Posts: 4

Original Poster
Rep: Reputation: 0
actually i have to build mpi library using which we can execute parallel programs in a cluster. whenever there is a failure of node its execution gets wasted, so to save this problem we store all that variables and from where the execution should start to some reliable source using some algorithm so that after failure we can extract those values and resume from where we got the failure.
 
Old 02-23-2008, 01:21 AM   #6
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
You'll have to write your state information out to a hard drive that is accessible to the cluster. Then in the event of a failure, another node can read in the state information and resume from the state that the failed one last wrote prior to the failure.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing a program in c daYz Programming 2 07-27-2007 03:34 PM
Temporary storage of password in shell script ansbaradigeidfran Programming 9 10-25-2006 09:03 AM
Variables invloved with working camera/usb storage device connection jimdaworm Slackware 2 04-25-2004 11:12 AM
Servlets executing a C program. webee Programming 1 02-04-2003 05:19 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:09 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration