1 /** @file snapshotimp.h
2 * @brief Snapshotting implementation header file..
12 #include <sys/types.h>
14 #define SHARED_MEMORY_DEFAULT (100 * ((size_t)1 << 20)) // 100mb for the shared memory
15 #define STACK_SIZE_DEFAULT (((size_t)1 << 20) * 20) // 20 mb out of the above 100 mb for my stack
17 #if USE_MPROTECT_SNAPSHOT
18 //Each snapshotrecord lists the firstbackingpage that must be written to revert to that snapshot
19 struct SnapShotRecord {
20 unsigned int firstBackingPage;
23 //Backing store page struct
28 //List the base address of the corresponding page in the backing store so we know where to copy it to
29 struct BackingPageRecord {
33 //Stuct for each memory region
35 void * basePtr; //base of memory region
36 int sizeInPages; //size of memory region in pages
39 //Primary struct for snapshotting system....
41 struct MemoryRegion * regionsToSnapShot; //This pointer references an array of memory regions to snapshot
42 struct SnapShotPage * backingStore; //This pointer references an array of snapshotpage's that form the backing store
43 void * backingStoreBasePtr; //This pointer references an array of snapshotpage's that form the backing store
44 struct BackingPageRecord * backingRecords; //This pointer references an array of backingpagerecord's (same number of elements as backingstore
45 struct SnapShotRecord * snapShots; //This pointer references the snapshot array
47 unsigned int lastSnapShot; //Stores the next snapshot record we should use
48 unsigned int lastBackingPage; //Stores the next backingpage we should use
49 unsigned int lastRegion; //Stores the next memory region to be used
51 unsigned int maxRegions; //Stores the max number of memory regions we support
52 unsigned int maxBackingPages; //Stores the total number of backing pages
53 unsigned int maxSnapShots; //Stores the total number of snapshots we allow
58 void *mSharedMemoryBase;
61 volatile snapshot_id mIDToRollback;
62 ucontext_t mContextToRollback;
63 snapshot_id currSnapShotID;
67 //Global reference to snapshot data structure
68 extern struct SnapShot * snapshotrecord;