inject failure according to exponential distribution
[charm.git] / src / ck-core / init.C
index 2f6d86c9972176435d212684f4cac22c4426b179..aa21e78eb1c1a220b8ebf98bfc228e7ad3a8acec 100644 (file)
@@ -202,10 +202,17 @@ extern int BUFFER_TIME; //time spent waiting for buffered messages
 
 // flag for killing processes 
 extern int killFlag;
+extern unsigned int failureSeed;
 // file specifying the processes to be killed
 extern char *killFile;
+//failure distribution
+extern char * failureDist;
+//mean time between failure in seconds
+extern int MTBF;
 // function for reading the kill file
 void readKillFile();
+// function to genrate failures according to distribution
+void generateFailure();
 
 
 int _defaultObjectQ = 0;            // for obejct queue
@@ -274,6 +281,27 @@ static inline void _parseCommandLineOpts(char **argv)
       }
     }
   }
+  
+  //reading failure distribution
+  if(CmiGetArgStringDesc(argv,"+failureInject", &failureDist,"Runtime system injects failure")){
+    if (CmiGetArgIntDesc(argv,"+MTBF",&MTBF,"Mean time between failures")){
+      killFlag = 2;
+      if(CmiMyPe()==0){
+        if(strcmp(failureDist, "E")==0){
+          printf("Runtime system generates faiures according to exponential distribution\n");
+        }else if(strcmp(failureDist, "W")==0){
+          printf("Runtime system generates faiures according to weibull distribution\n");
+        }
+      }
+      int seed;
+      if (!CmiGetArgIntDesc(argv,"+failureSeed",&seed,"seed to generate the random sequencea")){
+        CkAbort("Needs to provide failure seed");
+      }else{
+        failureSeed = seed;
+      }
+    }
+  }
+
 #endif
 
   // shut down program in ring fashion to allow projections output w/o IO error
@@ -1399,9 +1427,11 @@ void _initCharm(int unused_argc, char **argv)
 
 
 #if __FAULT__
-       if(killFlag){                                                  
+       if(killFlag == 1){ 
                 readKillFile();                                        
         }
+
+
 #endif
 
 }