X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=snapshot.cc;h=1f0cf352d2e214c0e5218818addb29fab2a37330;hb=HEAD;hp=1770fd648d414ef40cd064b1179ebbae3f65d85a;hpb=654801e1e81273424eaafce605bdeb882f3933d9;p=c11tester.git diff --git a/snapshot.cc b/snapshot.cc index 1770fd64..1f0cf352 100644 --- a/snapshot.cc +++ b/snapshot.cc @@ -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,30 +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); -} - -/** Assumes that addr is page aligned. */ -void snapshot_add_memory_region(void *addr, unsigned int numPages) -{ - /* not needed for fork-based snapshotting */ +void startExecution() { + fork_startExecution(); } /** Takes a snapshot of memory.