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