more documentation
authorBrian Demsky <bdemsky@uci.edu>
Wed, 6 Jun 2012 07:45:15 +0000 (00:45 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Wed, 6 Jun 2012 07:45:15 +0000 (00:45 -0700)
mymemory.cc
mymemory.h
snapshot-interface.cc
snapshot-interface.h
snapshot.cc
snapshot.h
snapshotimp.h

index 1dada053c2ba9060ed1c3301e3b895c44bf3855c..2b9c44d516282e1041487c6d0d1a5f1a78a1f472 100644 (file)
@@ -7,6 +7,8 @@
 static mspace sStaticSpace = NULL;
 #endif
 
 static mspace sStaticSpace = NULL;
 #endif
 
+/** Non-snapshotting malloc for our use. */
+
 void *MYMALLOC(size_t size) {
 #if USE_MPROTECT_SNAPSHOT
        static void *(*mallocp)(size_t size);
 void *MYMALLOC(size_t size) {
 #if USE_MPROTECT_SNAPSHOT
        static void *(*mallocp)(size_t size);
@@ -64,6 +66,8 @@ void system_free( void * ptr ){
        }
        freep(ptr);
 }
        }
        freep(ptr);
 }
+
+/** Non-snapshotting free for our use. */
 void MYFREE(void *ptr) {
 #if USE_MPROTECT_SNAPSHOT
        static void (*freep)(void *);
 void MYFREE(void *ptr) {
 #if USE_MPROTECT_SNAPSHOT
        static void (*freep)(void *);
@@ -82,33 +86,54 @@ void MYFREE(void *ptr) {
        mspace_free( sStaticSpace, ptr );
 #endif
 }
        mspace_free( sStaticSpace, ptr );
 #endif
 }
+
+
+/** This global references the mspace for the snapshotting heap */
 mspace mySpace = NULL;
 mspace mySpace = NULL;
+
+/** This global references the unaligned memory address that was malloced for the snapshotting heap */
 void * basemySpace = NULL;
 
 void * basemySpace = NULL;
 
+//Subramanian --- please make these work for the fork based approach
+
+/** Snapshotting malloc implementation for user programs. */
+
 void *malloc( size_t size ) {
        return mspace_malloc( mySpace, size );
 }
 
 void *malloc( size_t size ) {
        return mspace_malloc( mySpace, size );
 }
 
+/** Snapshotting free implementation for user programs. */
+
 void free( void * ptr ){
        mspace_free( mySpace, ptr );
 }
 
 void free( void * ptr ){
        mspace_free( mySpace, ptr );
 }
 
+/** Snapshotting realloc implementation for user programs. */
+
 void *realloc( void *ptr, size_t size ){
        return mspace_realloc( mySpace, ptr, size );
 }
 
 void *realloc( void *ptr, size_t size ){
        return mspace_realloc( mySpace, ptr, size );
 }
 
+/** Snapshotting new operator for user programs. */
+
 void * operator new(size_t size) throw(std::bad_alloc) {
        return malloc(size);
 }
 
 void * operator new(size_t size) throw(std::bad_alloc) {
        return malloc(size);
 }
 
+/** Snapshotting delete operator for user programs. */
+
 void operator delete(void *p) throw() {
        free(p);
 }
 
 void operator delete(void *p) throw() {
        free(p);
 }
 
+/** Snapshotting new[] operator for user programs. */
+
 void * operator new[](size_t size) throw(std::bad_alloc) {
        return malloc(size);
 }
 
 void * operator new[](size_t size) throw(std::bad_alloc) {
        return malloc(size);
 }
 
+/** Snapshotting delete[] operator for user programs. */
+
 void operator delete[](void *p, size_t size) {
        free(p);
 }
 void operator delete[](void *p, size_t size) {
        free(p);
 }
index f928797bc30f4aac90b45d25a342ab588cfa6a14..c159e532fd16b233c78ab26a4d3493f4f1e23cd2 100644 (file)
@@ -1,3 +1,7 @@
+/** @file mymemory.h
+ *  @brief Memory allocation functions.
+ */
+
 #ifndef _MY_MEMORY_H
 #define _MY_MEMORY_H
 #include <stdlib.h>
 #ifndef _MY_MEMORY_H
 #define _MY_MEMORY_H
 #include <stdlib.h>
index 58e1dd2ff3ae036a2011a0db24e1f95db03dcc60..c88e65ae5a5d4a0b35a9bbd9eebd5b0744442bfb 100644 (file)
 SnapshotStack * snapshotObject;
 
 #ifdef MAC
 SnapshotStack * snapshotObject;
 
 #ifdef MAC
+/** The SnapshotGlobalSegments function computes the memory regions
+ *     that may contain globals and then configures the snapshotting
+ *     library to snapshot them.
+ */
+
 void SnapshotGlobalSegments(){
        int pid = getpid();
        char buf[9000], execname[100];
 void SnapshotGlobalSegments(){
        int pid = getpid();
        char buf[9000], execname[100];
@@ -66,6 +71,10 @@ void SnapshotGlobalSegments(){
        pclose(map);
 }
 #else
        pclose(map);
 }
 #else
+/** The SnapshotGlobalSegments function computes the memory regions
+ *     that may contain globals and then configures the snapshotting
+ *     library to snapshot them.
+ */
 void SnapshotGlobalSegments(){
        int pid = getpid();
        char buf[9000], filename[100];
 void SnapshotGlobalSegments(){
        int pid = getpid();
        char buf[9000], filename[100];
@@ -94,8 +103,6 @@ void SnapshotGlobalSegments(){
 }
 #endif
 
 }
 #endif
 
-//class definition of SnapshotStack.....
-//declaration of constructor....
 SnapshotStack::SnapshotStack(){
        SnapshotGlobalSegments();
        stack=NULL;
 SnapshotStack::SnapshotStack(){
        SnapshotGlobalSegments();
        stack=NULL;
@@ -104,6 +111,14 @@ SnapshotStack::SnapshotStack(){
 SnapshotStack::~SnapshotStack(){
 }
 
 SnapshotStack::~SnapshotStack(){
 }
 
+
+/** This method returns to the last snapshot before the inputted
+ * sequence number.  This function must be called from the model
+ * checking thread and not from a snapshotted stack.  
+ * @param seqindex is the sequence number to rollback before.  
+ * @return is the sequence number we actually rolled back to.
+ */
+               
 int SnapshotStack::backTrackBeforeStep(int seqindex) {
        while(true) {
                if (stack->index<=seqindex) {
 int SnapshotStack::backTrackBeforeStep(int seqindex) {
        while(true) {
                if (stack->index<=seqindex) {
@@ -117,6 +132,9 @@ int SnapshotStack::backTrackBeforeStep(int seqindex) {
        }
 }
 
        }
 }
 
+/** This method takes a snapshot at the given sequence number.
+ */
+
 void SnapshotStack::snapshotStep(int seqindex) {
        struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry));
        tmp->next=stack;
 void SnapshotStack::snapshotStep(int seqindex) {
        struct stackEntry *tmp=(struct stackEntry *)MYMALLOC(sizeof(struct stackEntry));
        tmp->next=stack;
index 7e501fea4214292244273ebb806a3472591a8e09..1c4c32b0339c574bc7bde31096a78c2fec3a5932 100644 (file)
@@ -1,3 +1,8 @@
+/** @file snapshot-interface.h
+ *  @brief C++ layer on top of snapshotting system.
+ */
+
+
 #ifndef __SNAPINTERFACE_H
 #define __SNAPINTERFACE_H
 #include "mymemory.h"
 #ifndef __SNAPINTERFACE_H
 #define __SNAPINTERFACE_H
 #include "mymemory.h"
index ac4f712350aac33ab8f981b869d68a9500b4a76d..a5792e56f29e67c6b7810fb9691fa314ed04da73 100644 (file)
@@ -61,6 +61,10 @@ void initSnapShotRecord(unsigned int numbackingpages, unsigned int numsnapshots,
 }
 #endif //nothing to initialize for the fork based snapshotting.
 
 }
 #endif //nothing to initialize for the fork based snapshotting.
 
+/** HandlePF is the page fault handler for mprotect based snapshotting
+ * algorithm.
+ */
+
 void HandlePF( int sig, siginfo_t *si, void * unused){
 #if USE_MPROTECT_SNAPSHOT
        if( si->si_code == SEGV_MAPERR ){
 void HandlePF( int sig, siginfo_t *si, void * unused){
 #if USE_MPROTECT_SNAPSHOT
        if( si->si_code == SEGV_MAPERR ){
@@ -87,14 +91,18 @@ void HandlePF( int sig, siginfo_t *si, void * unused){
 #endif //nothing to handle for non snapshotting case.
 }
 
 #endif //nothing to handle for non snapshotting case.
 }
 
-//Return a page aligned address for the address being added
-//as a side effect the numBytes are also changed.
+/** ReturnPageAlignedAddress returns a page aligned address for the
+ * address being added as a side effect the numBytes are also changed.
+ */
+
 void * ReturnPageAlignedAddress(void * addr) {
        return (void *)(((uintptr_t)addr)&~(PAGESIZE-1));
 }
 
 void * ReturnPageAlignedAddress(void * addr) {
        return (void *)(((uintptr_t)addr)&~(PAGESIZE-1));
 }
 
-//Return a page aligned address for the address being added
-//as a side effect the numBytes are also changed.
+/** PageAlignedAdressUpdate return a page aligned address for the
+ * address being added as a side effect the numBytes are also changed.
+ */
+
 void * PageAlignAddressUpward(void * addr) {
        return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
 }
 void * PageAlignAddressUpward(void * addr) {
        return (void *)((((uintptr_t)addr)+PAGESIZE-1)&~(PAGESIZE-1));
 }
@@ -122,6 +130,10 @@ extern "C" {
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
+
+/** The initSnapShotLibrary function initializes the Snapshot library.
+ *  @param entryPoint the function that should run the program.
+ */
 void initSnapShotLibrary(unsigned int numbackingpages,
                unsigned int numsnapshots, unsigned int nummemoryregions,
                unsigned int numheappages, VoidFuncPtr entryPoint) {
 void initSnapShotLibrary(unsigned int numbackingpages,
                unsigned int numsnapshots, unsigned int nummemoryregions,
                unsigned int numheappages, VoidFuncPtr entryPoint) {
@@ -228,7 +240,9 @@ void initSnapShotLibrary(unsigned int numbackingpages,
 
 #endif
 }
 
 #endif
 }
-/* This function assumes that addr is page aligned */
+
+/** The addMemoryRegionToSnapShot function assumes that addr is page aligned. 
+ */
 void addMemoryRegionToSnapShot( void * addr, unsigned int numPages) {
 #if USE_MPROTECT_SNAPSHOT
        unsigned int memoryregion=snapshotrecord->lastRegion++;
 void addMemoryRegionToSnapShot( void * addr, unsigned int numPages) {
 #if USE_MPROTECT_SNAPSHOT
        unsigned int memoryregion=snapshotrecord->lastRegion++;
@@ -241,7 +255,11 @@ void addMemoryRegionToSnapShot( void * addr, unsigned int numPages) {
        snapshotrecord->regionsToSnapShot[ memoryregion ].sizeInPages=numPages;
 #endif //NOT REQUIRED IN THE CASE OF FORK BASED SNAPSHOTS.
 }
        snapshotrecord->regionsToSnapShot[ memoryregion ].sizeInPages=numPages;
 #endif //NOT REQUIRED IN THE CASE OF FORK BASED SNAPSHOTS.
 }
-//take snapshot
+
+/** The takeSnapshot function takes a snapshot.
+ * @return The snapshot identifier.
+ */
+
 snapshot_id takeSnapshot( ){
 #if USE_MPROTECT_SNAPSHOT
        for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {
 snapshot_id takeSnapshot( ){
 #if USE_MPROTECT_SNAPSHOT
        for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {
@@ -264,6 +282,11 @@ snapshot_id takeSnapshot( ){
        return snapshotid;
 #endif
 }
        return snapshotid;
 #endif
 }
+
+/** The rollBack function rollback to the given snapshot identifier.
+ *  @param theID is the snapshot identifier to rollback to.
+ */
+
 void rollBack( snapshot_id theID ){
 #if USE_MPROTECT_SNAPSHOT
        std::map< void *, bool, std::less< void * >, MyAlloc< std::pair< const void *, bool > > > duplicateMap;
 void rollBack( snapshot_id theID ){
 #if USE_MPROTECT_SNAPSHOT
        std::map< void *, bool, std::less< void * >, MyAlloc< std::pair< const void *, bool > > > duplicateMap;
@@ -303,6 +326,8 @@ void rollBack( snapshot_id theID ){
 #endif
 }
 
 #endif
 }
 
+/** The finalize method shuts down the snapshotting system.  */
+
 void finalize(){
 #if !USE_MPROTECT_SNAPSHOT
        sTheRecord->mbFinalize = true;
 void finalize(){
 #if !USE_MPROTECT_SNAPSHOT
        sTheRecord->mbFinalize = true;
index cc5e7e535408dd03a9002af41122ed5bfbe53476..03e020e801b55e781e2a88d5503b03b23c1a3d1c 100644 (file)
@@ -1,3 +1,7 @@
+/** @file snapshot.h
+ *     @brief Snapshotting interface header file.
+ */
+
 #ifndef _SNAPSHOT_H
 #define _SNAPSHOT_H
 
 #ifndef _SNAPSHOT_H
 #define _SNAPSHOT_H
 
index 8d935f238b81e3d43cf5ea1d7fdac07f583bc470..b918b8447b9b6f77b8b633ecdd835185997ddaa8 100644 (file)
@@ -1,3 +1,7 @@
+/** @file snapshotimp.h
+ *     @brief Snapshotting implementation header file..
+ */
+
 #ifndef _SNAPSHOTIMP_H
 #define _SNAPSHOTIMP_H
 #include "snapshot.h"
 #ifndef _SNAPSHOTIMP_H
 #define _SNAPSHOTIMP_H
 #include "snapshot.h"