let us set the size of the heap in a sane way
authorBrian Demsky <bdemsky@uci.edu>
Sat, 19 May 2012 01:14:26 +0000 (18:14 -0700)
committerBrian Demsky <bdemsky@uci.edu>
Sat, 19 May 2012 01:14:26 +0000 (18:14 -0700)
main.cc
mymemory.cc
mymemory.h
snapshot-interface.cc
snapshot.cc
snapshot.h

diff --git a/main.cc b/main.cc
index e629f6092992ce8fb59a80a7e14388b7b7724143..4de59674c8a2410fa6717c656e8746636ec3b6e1 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -78,5 +78,5 @@ int main(int numargs, char ** args) {
   main_args=args;
 
   /* Let's jump in quickly and start running stuff */
   main_args=args;
 
   /* Let's jump in quickly and start running stuff */
-  initSnapShotLibrary(10000 /*int numbackingpages*/, 1024 /*unsigned int numsnapshots*/, 1024 /*unsigned int nummemoryregions*/ , &real_main /*MyFuncPtr entryPoint*/);
+  initSnapShotLibrary(10000 /*int numbackingpages*/, 1024 /*unsigned int numsnapshots*/, 1024 /*unsigned int nummemoryregions*/ , 1000 /*int numheappages*/, &real_main /*MyFuncPtr entryPoint*/);
 }
 }
index ac46b1178df29eeabacdd063f85cbd9783dc5260..891a93f0d56c6b0fb083af75701badbafdb01041 100644 (file)
@@ -52,13 +52,8 @@ void MYFREE(void *ptr) {
   mspace_free( sStaticSpace, ptr );
 #endif
 }
   mspace_free( sStaticSpace, ptr );
 #endif
 }
-static mspace mySpace = NULL;
+mspace mySpace = NULL;
 void *malloc( size_t size ) {
 void *malloc( size_t size ) {
-  if( NULL == mySpace ){
-    //void * mem = MYMALLOC( MSPACE_SIZE );
-    mySpace = create_mspace( MSPACE_SIZE, 1 );
-    AddUserHeapToSnapshot();
-  }
   return mspace_malloc( mySpace, size );
 }
 
   return mspace_malloc( mySpace, size );
 }
 
@@ -66,13 +61,6 @@ void free( void * ptr ){
   mspace_free( mySpace, ptr );
 }
 
   mspace_free( mySpace, ptr );
 }
 
-void AddUserHeapToSnapshot(){
-  static bool alreadySnapshotted = false;
-  if( alreadySnapshotted ) return;
-  addMemoryRegionToSnapShot( mySpace, MSPACE_SIZE / PAGESIZE );
-}
-
-
 void * operator new(size_t size) throw(std::bad_alloc) {
   return MYMALLOC(size);
 }
 void * operator new(size_t size) throw(std::bad_alloc) {
   return MYMALLOC(size);
 }
index f2f2c2b852b68f8e3f8076b66753792cc907680a..2bec138381e45768d9d6f2129824eca9ebdc23e9 100644 (file)
@@ -18,7 +18,6 @@
 
 void *MYMALLOC(size_t size);
 void MYFREE(void *ptr);
 
 void *MYMALLOC(size_t size);
 void MYFREE(void *ptr);
-void AddUserHeapToSnapshot();                                                                                          
 /*
 The following code example is taken from the book
 The C++ Standard Library - A Tutorial and Reference
 /*
 The following code example is taken from the book
 The C++ Standard Library - A Tutorial and Reference
@@ -109,7 +108,6 @@ template <class T>
      return false;
  }
 
      return false;
  }
 
-
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -118,6 +116,7 @@ extern void* mspace_malloc(mspace msp, size_t bytes);
 extern void mspace_free(mspace msp, void* mem);
 extern mspace create_mspace_with_base(void* base, size_t capacity, int locked);
 extern mspace create_mspace(size_t capacity, int locked);
 extern void mspace_free(mspace msp, void* mem);
 extern mspace create_mspace_with_base(void* base, size_t capacity, int locked);
 extern mspace create_mspace(size_t capacity, int locked);
+extern mspace mySpace;
 #ifdef __cplusplus
 };  /* end of extern "C" */
 #endif
 #ifdef __cplusplus
 };  /* end of extern "C" */
 #endif
index 2ee01a46bb5442a15ac0302bf5390280b7a983c6..952d7906c984a75f32be66b45c11eed8ca105611 100644 (file)
@@ -77,7 +77,6 @@ void SnapshotGlobalSegments(){
 //declaration of constructor....
 snapshotStack::snapshotStack(){
   SnapshotGlobalSegments();
 //declaration of constructor....
 snapshotStack::snapshotStack(){
   SnapshotGlobalSegments();
-  AddUserHeapToSnapshot();
   stack=NULL;
 }
        
   stack=NULL;
 }
        
index 8761862ca5f67e01e431fd9de006dab095b7dd6b..b848d024c4eab7a0efe39f6f9693c680bdae3aa6 100644 (file)
@@ -123,7 +123,7 @@ void createSharedLibrary(){
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
-void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions , MyFuncPtr entryPoint){
+void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions, unsigned int numheappages, MyFuncPtr entryPoint){
 #if USE_CHECKPOINTING
   struct sigaction sa;
   sa.sa_flags = SA_SIGINFO | SA_NODEFER | SA_RESTART;
 #if USE_CHECKPOINTING
   struct sigaction sa;
   sa.sa_flags = SA_SIGINFO | SA_NODEFER | SA_RESTART;
@@ -134,6 +134,8 @@ void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots
     exit(-1);
   }
   initSnapShotRecord(numbackingpages, numsnapshots, nummemoryregions);
     exit(-1);
   }
   initSnapShotRecord(numbackingpages, numsnapshots, nummemoryregions);
+  mySpace = create_mspace( numheappages*PAGESIZE, 1 );
+  addMemoryRegionToSnapShot(mySpace, numheappages);
   entryPoint();
 #else
   //add a signal to indicate that the process is going to terminate.
   entryPoint();
 #else
   //add a signal to indicate that the process is going to terminate.
index 16d9cd76a30dd3e6d99874b2fb565813b31241b1..a0f2757dc19496ab7d1155bfba983954127d7b14 100644 (file)
@@ -5,7 +5,7 @@
 
 typedef unsigned int snapshot_id;
 typedef void (*MyFuncPtr)();
 
 typedef unsigned int snapshot_id;
 typedef void (*MyFuncPtr)();
-void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions, MyFuncPtr entryPoint);
+void initSnapShotLibrary(unsigned int numbackingpages, unsigned int numsnapshots, unsigned int nummemoryregions, unsigned int numheappages, MyFuncPtr entryPoint);
 
 void addMemoryRegionToSnapShot( void * ptr, unsigned int numPages );
 
 
 void addMemoryRegionToSnapShot( void * ptr, unsigned int numPages );