473,378 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How do I save the memory state of a C program so I can jumpstart later

In a large complex C program, I wish to save - to a file - the contents of all memory that is used by static variables, global structures and dynamically allocated variables. Then, in a separate execution of the program, I want to initialize the memory from this saved state. If this is even possible, can someone offer an approach to accomplish this? This has to do with jump-starting a trajectory simulation from a previously saved state.
Jul 12 '10 #1
2 2786
Banfa
9,065 Expert Mod 8TB
I am not aware of any generic approach to this. Remember you would not just need the state of all variables but the run state of all threads.

I am not saying it can't be done just that any solution is likely to be application specific and probably needs to be designed in from the ground up.

Not having any static/global data and allocating everything from the heap may help. The reason being you can intercept heap allocations which gives you easy access to the data for saving program state by having a central repository for all data.

Additionally while you are saving you will need to ensure all threads are halted. It will do no good to save program state if between the start and the end of the save 1 or more threads alter some of the data.
Jul 12 '10 #2
weaknessforcats
9,208 Expert Mod 8TB
Are you able to make a system call for a context switch?

Whenever you change threads, the OS has to save the state of the machine so the new thread can't screw up the old thread.
Jul 14 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Arnold | last post by:
I need to modify my existing program into two separate executables. The first exe will be executed once to initiate a hardware card, the second program exe can be called multiple times to process...
5
by: John | last post by:
Hi, I have an application which is built from many modules. I re-use the modules in different applications. I'd like to have each of my modules implement a "SaveState()" method. The method...
1
by: R. Sammut | last post by:
Hi, I have a treeview control that is updated every 30 seconds. The treeview nodes are cleared and new nodes (same number of nodes and hierarchy) are added to the treeview. Now I need to save...
14
by: fdu.xiaojf | last post by:
Hi, I have a program which will continue to run for several days. When it is running, I can't do anything except waiting because it takes over most of the CUP time. Is it possible that the...
1
by: Benny | last post by:
I need to populate a table with information then in a seperate utility, in the same application, pull that data using the same criteria that was first used and update some values, unique to an id,...
7
by: newscorrespondent | last post by:
I want to save the state of a splitcontainer when an application ends. I also save the form state. The SplitContainer does not seem to have a well defined place to put intiialization and...
6
by: Jason Zapman II | last post by:
I've written a program. To install this program, I'm going to need to initialize some stuff for the users environment, specifically the name/ location of an internal state file. Currently, I'm...
4
by: remlostime | last post by:
now, i wanna how much memory my program use, what code should i add to my code, or is there some program that can test it?
1
by: Allen | last post by:
I'm using the turtle module in Python. Is there a way to save the turle state at any moment for recursive algorithms to easily return the turtle to an earlier point for another branch/etc? ...
3
drhowarddrfine
by: drhowarddrfine | last post by:
After two days of working on this bug, I just got it working but I don't know why. I'm throwing this out there in hopes someone recognizes it but I think everyone will say it doesn't make sense. ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.