-void rollBack( snapshot_id theID ){
-#if USE_MPROTECT_SNAPSHOT==2
- if (snapshotrecord->lastSnapShot==(theID+1)) {
- for(unsigned int page=snapshotrecord->snapShots[theID].firstBackingPage; page<snapshotrecord->lastBackingPage; page++) {
- memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage));
- }
- return;
- }
-#endif
-
-#if USE_MPROTECT_SNAPSHOT
- HashTable< void *, bool, uintptr_t, 4, model_malloc, model_calloc, model_free> duplicateMap;
- for(unsigned int region=0; region<snapshotrecord->lastRegion;region++) {
- if( mprotect(snapshotrecord->regionsToSnapShot[region].basePtr, snapshotrecord->regionsToSnapShot[region].sizeInPages*sizeof(struct SnapShotPage), PROT_READ | PROT_WRITE ) == -1 ){
- perror("mprotect");
- printf("Failed to mprotect inside of takeSnapShot\n");
- exit(EXIT_FAILURE);
- }
- }
- for(unsigned int page=snapshotrecord->snapShots[theID].firstBackingPage; page<snapshotrecord->lastBackingPage; page++) {
- if( !duplicateMap.contains(snapshotrecord->backingRecords[page].basePtrOfPage )) {
- duplicateMap.put(snapshotrecord->backingRecords[page].basePtrOfPage, true);
- memcpy(snapshotrecord->backingRecords[page].basePtrOfPage, &snapshotrecord->backingStore[page], sizeof(struct SnapShotPage));
- }
- }
- snapshotrecord->lastSnapShot=theID;
- snapshotrecord->lastBackingPage=snapshotrecord->snapShots[theID].firstBackingPage;
- takeSnapshot(); //Make sure current snapshot is still good...All later ones are cleared
-#else
- snapshotrecord->mIDToRollback = theID;
- volatile int sTemp = 0;
- getcontext( &snapshotrecord->mContextToRollback );
- /*
- * This is used to quit the process on rollback, so that the process
- * which needs to rollback can quit allowing the process whose
- * snapshotid matches the rollbackid to switch to this context and
- * continue....
- */
- if( !sTemp ){
- sTemp = 1;
- SSDEBUG("Invoked rollback\n");
- exit(EXIT_SUCCESS);
- }
- /*
- * This fix obviates the need for a finalize call. hence less dependences for model-checker....
- *
- */
- snapshotrecord->mIDToRollback = -1;
-#endif