コード例 #1
0
ファイル: basic9.c プロジェクト: Machiry/AOS
/* proc1 writes some data, commits it, then exits */
void proc1() 
{
     rvm_t rvm;
     trans_t trans;
     char* segs[1];
     
     rvm = rvm_init(__FILE__ ".d");
     rvm_destroy(rvm, "testseg");
     segs[0] = (char *) rvm_map(rvm, "testseg", 10000);

     trans = rvm_begin_trans(rvm, 1, (void **) segs);
     rvm_about_to_modify(trans, segs[0], 0, 100);
     sprintf(segs[0], "one");
     rvm_commit_trans(trans);

     trans = rvm_begin_trans(rvm, 1, (void **) segs);
     rvm_about_to_modify(trans, segs[0], 0, 100);
     sprintf(segs[0], "two");
     rvm_abort_trans(trans);

     trans = rvm_begin_trans(rvm, 1, (void **) segs);
     rvm_about_to_modify(trans, segs[0], 0, 100);
     sprintf(segs[0], "foo");
     rvm_commit_trans(trans);

     abort();
}
コード例 #2
0
ファイル: multi-trans.c プロジェクト: kandycs/lrvm
void proc1() 
{
     rvm_t rvm;
     char* segs[2];
     trans_t trans[2];
     
     rvm = rvm_init("rvm_segments");

     rvm_destroy(rvm, SEGNAME0);
     rvm_destroy(rvm, SEGNAME1);

     segs[0] = (char*) rvm_map(rvm, SEGNAME0, 1000);
     segs[1] = (char*) rvm_map(rvm, SEGNAME1, 1000);

     trans[0] = rvm_begin_trans(rvm, 1, &segs[0]);
     trans[1] = rvm_begin_trans(rvm, 1, &segs[1]);

     rvm_about_to_modify(trans[0], segs[0], OFFSET0, 100);
     strcpy(segs[0]+OFFSET0, STRING0);
     rvm_about_to_modify(trans[1], segs[1], OFFSET1, 100);
     strcpy(segs[1]+OFFSET1, STRING1);

     rvm_commit_trans(trans[0]);
     rvm_commit_trans(trans[1]);
	
	 rvm_unmap(rvm, segs[0]);
	 rvm_unmap(rvm, segs[1]);
}
コード例 #3
0
ファイル: test_multi1.c プロジェクト: Machiry/AOS
void proc1() 
{
     rvm_t rvm;
     char* segs[2];
     trans_t trans;
     char** segnames;
     int i;
     int numSegments = 100;

     rvm = rvm_init(__FILE__ ".d");
     
     // Allocate some memory
     segnames = (char **)malloc(numSegments * sizeof(char *));
     
    for(i = 0; i < numSegments; i++) {
      segnames[i] = (char *)malloc(MAX_SEGMENT_NAME_LEN);   
      sprintf(segnames[i],"testseg%i",i);
      rvm_destroy(rvm, segnames[i]);
    }

    
    //all segments contain the first string (aa)
    for(i = 0; i < numSegments; i++) {
      
      segs[0] = (char *) rvm_map(rvm, segnames[i], 3);
      trans = rvm_begin_trans(rvm, 1, (void **) segs);
      rvm_about_to_modify(trans, segs[0], 0, 3); 
      sprintf(segs[0],"aa");
      rvm_commit_trans(trans);
      rvm_unmap(rvm,segs[0]);
    }

    
    //only even segments contain the second string (modify aa to ab)
    for(i = 0; i < numSegments; i++) {
      segs[0] = (char *) rvm_map(rvm, segnames[i], 3);
      trans = rvm_begin_trans(rvm, 1, (void **) segs);
      rvm_about_to_modify(trans, segs[0], 1, 1); 
      segs[0][1]='b';
      assert(strcmp("ab", segs[0]) == 0);
      if(i%2==0){ //the modulus is 1, we are even
	rvm_commit_trans(trans);
      }
    }
    

    // Free memory
    for(i = 0; i < numSegments; i++) {
      free(segnames[i]);
    }
    free(segnames);
}
コード例 #4
0
ファイル: segfault.c プロジェクト: Goldensunboy/cs4210-proj4
void proc1() 
{
     rvm_t rvm;
     char* segs[2];
     trans_t trans;
     
     rvm = rvm_init("rvm_segments");

     rvm_destroy(rvm, SEGNAME0);
     rvm_destroy(rvm, SEGNAME1);

     segs[0] = (char*) rvm_map(rvm, SEGNAME0, 1000);
     segs[1] = (char*) rvm_map(rvm, SEGNAME1, 1000);

     trans = rvm_begin_trans(rvm, 2, (void **)segs);

     rvm_about_to_modify(trans, segs[0], OFFSET0, 100);
     strcpy(segs[0]+OFFSET0, STRING0);
     rvm_about_to_modify(trans, segs[1], OFFSET1, 100);
     strcpy(segs[1]+OFFSET1, STRING1);

     rvm_commit_trans(trans);

	 char *str;
     (str = strdup("foo"))[3] = '\n';
     printf("Length of foo: %d\n", strlen(str));
}
コード例 #5
0
ファイル: test_deception.c プロジェクト: kszr/recoverable-vm
/* proc1 writes some data, commits it, then exits */
void proc1() 
{
     rvm_t rvm;
     trans_t trans;
     char* segs[1];
     
     rvm = rvm_init("rvm_segments");
     rvm_destroy(rvm, "testseg");
     segs[0] = (char *) rvm_map(rvm, "testseg", 10000);

     
     trans = rvm_begin_trans(rvm, 1, (void **) segs);
     
    //  rvm_about_to_modify(trans, segs[0], 0, 100);
    //  sprintf(segs[0], TEST_STRING);
    //  printf("Segment Data %s\n", segs[0]);
     rvm_about_to_modify(trans, segs[0], OFFSET2, 100);
     sprintf(segs[0]+OFFSET2, TEST_STRING);
     sprintf(segs[0], BAD_STRING);
     printf("Segment Data %s\n", segs[0]);
     
     rvm_commit_trans(trans);

     abort();
}
コード例 #6
0
ファイル: rvm_main.c プロジェクト: wanchen1112/CS6210_Lab_4
void proc1() 
{
     rvm_t rvm;
     char* segs[2];
     trans_t trans;
     
     printf(">>> proc1()\n");

     rvm = rvm_init("rvm_segments");

     rvm_destroy(rvm, SEGNAME0);
     rvm_destroy(rvm, SEGNAME1);

     segs[0] = (char*) rvm_map(rvm, SEGNAME0, 1000);
     segs[1] = (char*) rvm_map(rvm, SEGNAME1, 1000);

     segs[0] = (char*) rvm_map(rvm, SEGNAME0, 300);

     trans = rvm_begin_trans(rvm, 2, (void **)segs);

     rvm_about_to_modify(trans, segs[0], OFFSET0, 100);
     strcpy(segs[0]+OFFSET0, STRING0);
     rvm_about_to_modify(trans, segs[1], OFFSET1, 100);
     strcpy(segs[1]+OFFSET1, STRING1);

     rvm_commit_trans(trans);

     abort();
}
コード例 #7
0
ファイル: test3.c プロジェクト: gajayraghav/VRM
/* proc1 writes some data, commits it, then exits */
void proc1() 
{		 
     rvm_t rvm;
     trans_t trans;
     char* segs[1];
     
     rvm = rvm_init("rvm_segments");
     rvm_destroy(rvm, "testseg");
     segs[0] = (char *) rvm_map(rvm, "testseg", 1000);

     
     trans = rvm_begin_trans(rvm, 1, (void **) segs);
     
     rvm_about_to_modify(trans, segs[0], 0, 1000);
     char * currChar = segs[0];
     for (int counter= 0; counter < 1000; counter++){
       *currChar = '!';
       currChar++;
     }
     
     rvm_commit_trans(trans);
     
     

     abort();
}
コード例 #8
0
ファイル: test01.c プロジェクト: dmanatunga/cs6210-project4
int main(int argc, char** argv) {
  rvm_t rvm;
  trans_t trans;
  char* segs[1];

  rvm = rvm_init("rvm_segments");
  rvm_destroy(rvm, "testseg01");
  segs[0] = (char*) rvm_map(rvm, "testseg01", 10000);

  trans = rvm_begin_trans(rvm, 1, (void**) segs);

  rvm_about_to_modify(trans, segs[0], 0, 100);
  sprintf(segs[0], TEST_STRING);

  rvm_about_to_modify(trans, segs[0], OFFSET2, 100);
  sprintf(segs[0] + OFFSET2, TEST_STRING);

  rvm_commit_trans(trans);

  // This should fail
  rvm_destroy(rvm, "testseg01");

  rvm_unmap(rvm, segs[0]);

  rvm_truncate_log(rvm);

  if (file_exists("rvm_segments/seg_testseg01.rvm")) {
    printf("OK\n");
  } else {
    printf("ERROR: Segment file no longer present");
  }

  return 0;
}
/* create the scenario */
void create() 
{
     
  // rvm_t rvm = rvm_init(__FILE__ ".d");
  rvm_t rvm = rvm_init("rvm_segments");
     rvm_destroy(rvm, "testseg");
     char* segs[1];


     /*-- without unmapping (first half of segment) --*/
     segs[0] = (char *) rvm_map(rvm, "testseg", 10);
     trans_t tid = rvm_begin_trans(rvm, 1, (void **) segs);
     rvm_about_to_modify(tid, segs[0], 0, 5);
     sprintf(segs[0], "foo"); /* write "foo" */
     rvm_commit_trans(tid);

     tid = rvm_begin_trans(rvm, 1, (void **) segs);
     segs[0][0] = 'b'; /* change to boo without logging */
     assert(strcmp(segs[0], "boo") == 0); /* ensure change */
     rvm_commit_trans(tid);



     /*-- unmap and remap (second half of segment) --*/
     tid = rvm_begin_trans(rvm, 1, (void **) segs);
     rvm_about_to_modify(tid, segs[0], 4, 5);
     sprintf(segs[0] + 4, "bar"); /* write "bar" */
     rvm_commit_trans(tid);
     rvm_unmap(rvm, segs[0]);

     segs[0] = (char *) rvm_map(rvm, "testseg", 10);
     tid = rvm_begin_trans(rvm, 1, (void **) segs);
     segs[0][6] = 'z'; /* change to baz without logging */
     assert(strcmp(segs[0] + 4, "baz") == 0); /* ensure change */
     rvm_commit_trans(tid);



     abort();
}
コード例 #10
0
ファイル: abort.c プロジェクト: j3gb3rt/CS4210Proj4
int main(int argc, char **argv)
{
     rvm_t rvm;
     char *seg;
     void *segs[1];
     trans_t trans;
     
     rvm = rvm_init("rvm_segments");
     
     rvm_destroy(rvm, "testseg");
     
     seg = (char *) rvm_map(rvm, "testseg", 10000);
	 segs[0] = seg;

     /* write some data and commit it */
     trans = rvm_begin_trans(rvm, 1, segs);
     rvm_about_to_modify(trans, seg, 0, 100);
     sprintf(seg, TEST_STRING1);
     
     rvm_about_to_modify(trans, seg, OFFSET2, 100);
     sprintf(seg+OFFSET2, TEST_STRING1);
     
     rvm_commit_trans(trans);

     /* start writing some different data, but abort */
     trans = rvm_begin_trans(rvm, 1, segs);
     rvm_about_to_modify(trans, seg, 0, 100);
     sprintf(seg, TEST_STRING2);
     
     rvm_about_to_modify(trans, seg, OFFSET2, 100);
     sprintf(seg+OFFSET2, TEST_STRING2);

	 rvm_abort_trans(trans);

     /* test that the data was restored */
     if(strcmp(seg+OFFSET2, TEST_STRING1)) {
	  printf("ERROR: second hello is incorrect (%s)\n",
		 seg+OFFSET2);
	  exit(2);
     }

     if(strcmp(seg, TEST_STRING1)) {
	  printf("ERROR: first hello is incorrect (%s)\n",
		 seg);
	  exit(2);
     }
     

     rvm_unmap(rvm, seg);
     printf("OK\n");
     exit(0);
}
コード例 #11
0
ファイル: abouttomodify2.c プロジェクト: netrakenkarey/RVM
int main(int argc, char **argv)
{
     rvm_t rvm;
     char* segs[2];
     char* badsegs;
     trans_t trans;

     /* initialize */
     rvm = rvm_init("rvm_segments");

     rvm_destroy(rvm, SEGNAME0);
     rvm_destroy(rvm, SEGNAME1);
     rvm_destroy(rvm, SEGNAME2);

     segs[0] = (char*) rvm_map(rvm, SEGNAME0, 1000);
     segs[1] = (char*) rvm_map(rvm, SEGNAME1, 1000);
     badsegs = (char*) rvm_map(rvm, SEGNAME2, 1000);


     /* write in some initial data */
     trans = rvm_begin_trans(rvm, 2, (void **) segs);

     rvm_about_to_modify(trans, segs[0], OFFSET0, 100);
     strcpy(segs[0]+OFFSET0, GOOD_STRING);
     rvm_about_to_modify(trans, badsegs, OFFSET0, 100);
     strcpy(badsegs+OFFSET0, GOOD_STRING);

     rvm_commit_trans(trans);

     /* test the strings */
     if(strcmp(badsegs + OFFSET0, GOOD_STRING)) {
	  printf("ERROR segment not mentioned in rvm_begin_trans yet modifications made (%s)\n",
		 badsegs+OFFSET0);
	  exit(2);
     }

     printf("OK\n");
     return 0;
}
コード例 #12
0
ファイル: test6.c プロジェクト: gajayraghav/VRM
/* proc1 writes some data, commits it, then exits */
void proc1() {
	rvm_t rvm;
	char *seg;
	char *segs[1];
	trans_t trans;

	rvm = rvm_init("rvm_segments");

	rvm_destroy(rvm, "testseg");

	segs[0] = (char *) rvm_map(rvm, "testseg", 10000);
	seg = segs[0];

	/* write some data and commit it */
	trans = rvm_begin_trans(rvm, 1, (void**) segs);
	rvm_about_to_modify(trans, seg, 0, 100);
	sprintf(seg, TEST_STRING1);

	rvm_about_to_modify(trans, seg, OFFSET2, 100);
	sprintf(seg + OFFSET2, TEST_STRING2);

	rvm_about_to_modify(trans, seg, OFFSET3, 100);
	sprintf(seg + OFFSET3, TEST_STRING3);
	rvm_commit_trans(trans);

	/* start writing some different data, but abort */
	trans = rvm_begin_trans(rvm, 1, (void**) segs);
	rvm_about_to_modify(trans, seg, 0, 100);
	sprintf(seg, TEST_STRING4);

	rvm_about_to_modify(trans, seg, OFFSET2, 100);
	sprintf(seg + OFFSET2, TEST_STRING5);

	rvm_about_to_modify(trans, seg, OFFSET3, 100);
	sprintf(seg + OFFSET3, TEST_STRING6);
	rvm_abort_trans(trans);
	abort();
}
コード例 #13
0
ファイル: bad_unmap.c プロジェクト: indianburger/aosp4
int main(int argc, char **argv)
{
     rvm_t rvm;
     char *seg;
     void *segs[1];
     trans_t trans;
     
     rvm = rvm_init("rvm_segments");
     
     segs[0] = (char *) rvm_map(rvm, "testseg", 10000);
     seg = (char *) segs[0];

     fprintf(stderr, "\nThere should be an error below that segment cannot be unmapped\n");
     trans = rvm_begin_trans(rvm, 1, segs);
     rvm_about_to_modify(trans, seg, 0, 100);
     sprintf(seg, TEST_STRING1);
     
     rvm_unmap(rvm, (void*)trans); 
     
     rvm_commit_trans(trans);

     exit(0);
}