GithubHelp home page GithubHelp logo

akshayojha / checkpoint-recover-single-threaded-applications Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 144 KB

This software creates checkpoint images of single threaded C/C++ applications at runtime and continues them later

C 88.41% Makefile 11.59%

checkpoint-recover-single-threaded-applications's Introduction

Checkpoint-Recover-Single-Threaded-Applications

This software creates checkpoint images of single threaded C/C++ applications at runtime and continues them later using the image.

The idea is simple and as follows:

  1. Compile the target C/C++ program application statically with our checkpointing program(ckpt.c)

  2. Now run the output of the above compilation and send SIGUSR2 signal(Can be easily changed to any other type of signal in ckpt.c) to the running target process.

  3. A checkpoint image file will be created which needs to be given as input to restart program(myrestart.c)

  4. The restart program will then respawn the target process from the exact same point it was stopped from a signal.

How does it works?

Idea is pretty simple and amazing! Whenever a process is being run on Linux distributions, its memory map can be accessed by /proc/(pid of the process)/maps. This file contains all the information we need. It contains memory address range used by stack and heap of the process and basically everything that makes it run and identifies its state. We can store the binary data in these ranges to a local file along with the memory ranges they belong to. We can later use this file and map back all the data it had to the exact memory locations which will simply respawn the process.

For details about how to compile, compiler flags to use etc. refer to the makefile. I have also provided a sample program(hello.c) to test the software.

To do:

  1. Add multithreading application support

  2. Allow creating of multiple checkpoints in a single run

  3. Use more efficient ways to parse the proc map file

checkpoint-recover-single-threaded-applications's People

Contributors

akshayojha avatar

Watchers

 avatar

checkpoint-recover-single-threaded-applications's Issues

Error in 'make'

Hello, I tried your program and ran make on my server, and it quitted at the read function, at line 50 of myrestart.c. The bytes read by function is not equal to size, so it quitted.
Can you give some hint to solve this problem?

This is detailed info:

# user @ pm1 in ~/sjj/single-thread-ck/Checkpoint-Recover-Single-Threaded-Applications-master [17:24:36] 
$ make
rm -rf myckpt myckpt.tmp myrestart hello ckpt ckpt.o libckpt.a
gcc -c -o ckpt.o ckpt.c && ar rcs libckpt.a ckpt.o
gcc -g -static -L`pwd` -lckpt -Wl,-u,capture_signal -o hello hello.c
gcc -g -static -Wl,-Ttext=5000000 -Wl,-Tdata=5100000 -Wl,-Tbss=5200000 -o myrestart myrestart.c
myrestart.c: In function ‘parsefile’:
myrestart.c:52:26: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 2 has type ‘void *’ [-Wformat=]
         printf("start: %lu, size: %lu, read_res: %lu\n", start, size, read_res);
                        ~~^
                        %p
(sleep 3 && kill -12 `pgrep -n hello` && sleep 2 && pkill -9 hello) & 
./hello
0       1       2       3       (sleep 2 &&  pkill -9 myrestart) &
make restart
make[1]: Entering directory '/home/user/sjj/single-thread-ck/Checkpoint-Recover-Single-Threaded-Applications-master'
./myrestart myckpt
start: 140721247547392, size: 12288, read_res: 9064
Error in reading!
: Success
make[1]: Leaving directory '/home/user/sjj/single-thread-ck/Checkpoint-Recover-Single-Threaded-Applications-master'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.