Change initialize a bit
[c11tester.git] / snapshot.cc
index c049167e52bb753e35dcb4dca11c45da821bc5cb..1f0cf352d2e214c0e5218818addb29fab2a37330 100644 (file)
@@ -64,7 +64,6 @@ ucontext_t shared_ctxt;
  *   snapshotid. it is incremented and set in a persistently shared record
  */
 static ucontext_t private_ctxt;
-static ucontext_t exit_ctxt;
 static snapshot_id snapshotid = 0;
 
 /**
@@ -107,6 +106,7 @@ static void createSharedMemory()
        fork_snap->mStackSize = STACK_SIZE_DEFAULT;
        fork_snap->mIDToRollback = -1;
        fork_snap->currSnapShotID = 0;
+       sStaticSpace = create_shared_mspace();
 }
 
 /**
@@ -122,9 +122,7 @@ mspace create_shared_mspace()
        return create_mspace_with_base((void *)(fork_snap->mSharedMemoryBase), SHARED_MEMORY_DEFAULT - sizeof(*fork_snap), 1);
 }
 
-static void fork_snapshot_init(unsigned int numbackingpages,
-                                                                                                                        unsigned int numsnapshots, unsigned int nummemoryregions,
-                                                                                                                        unsigned int numheappages)
+static void fork_snapshot_init(unsigned int numheappages)
 {
        if (!fork_snap)
                createSharedMemory();
@@ -170,13 +168,7 @@ static void fork_loop() {
        }
 }
 
-static void fork_startExecution(ucontext_t *context, VoidFuncPtr entryPoint) {
-       /* setup an "exiting" context */
-       int exit_stack_size = 256;
-       create_context(&exit_ctxt, snapshot_calloc(exit_stack_size, 1), exit_stack_size, fork_exit);
-
-       /* setup the system context */
-       create_context(context, fork_snap->mStackBase, STACK_SIZE_DEFAULT, entryPoint);
+static void fork_startExecution() {
        /* switch to a new entryPoint context, on a new stack */
        create_context(&private_ctxt, snapshot_calloc(STACK_SIZE_DEFAULT, 1), STACK_SIZE_DEFAULT, fork_loop);
 }
@@ -184,6 +176,7 @@ static void fork_startExecution(ucontext_t *context, VoidFuncPtr entryPoint) {
 static snapshot_id fork_take_snapshot() {
        model_swapcontext(&shared_ctxt, &private_ctxt);
        DEBUG("TAKESNAPSHOT RETURN\n");
+       fork_snap->mIDToRollback = -1;
        return snapshotid;
 }
 
@@ -191,24 +184,20 @@ static void fork_roll_back(snapshot_id theID)
 {
        DEBUG("Rollback\n");
        fork_snap->mIDToRollback = theID;
-       model_swapcontext(model->get_system_context(), &exit_ctxt);
-       fork_snap->mIDToRollback = -1;
+       fork_exit();
 }
 
 /**
  * @brief Initializes the snapshot system
  * @param entryPoint the function that should run the program.
  */
-void snapshot_system_init(unsigned int numbackingpages,
-                                                                                                       unsigned int numsnapshots, unsigned int nummemoryregions,
-                                                                                                       unsigned int numheappages)
+void snapshot_system_init(unsigned int numheappages)
 {
-       fork_snapshot_init(numbackingpages, numsnapshots, nummemoryregions, numheappages);
+       fork_snapshot_init(numheappages);
 }
 
-void startExecution(ucontext_t *context, VoidFuncPtr entryPoint)
-{
-       fork_startExecution(context, entryPoint);
+void startExecution() {
+       fork_startExecution();
 }
 
 /** Takes a snapshot of memory.