Add support to limit the number of checkpoints dropped.
authorNathan Binkert <binkertn@umich.edu>
Wed, 13 Apr 2005 13:38:50 +0000 (09:38 -0400)
committerNathan Binkert <binkertn@umich.edu>
Wed, 13 Apr 2005 13:38:50 +0000 (09:38 -0400)
sim/serialize.hh:
    Add variables to keep track of the number of checkpoints
    dropped and maximum allowed.

--HG--
extra : convert_revision : 32241b90c58def6958ec84c53cc2cca996007506

sim/serialize.cc
sim/serialize.hh

index 846d191e0a6fad539b078e14fa4fa9c63dc099b8..1976e6b3c7e34b051e4fbf8014995ef9ab8e2b39 100644 (file)
@@ -50,6 +50,9 @@
 
 using namespace std;
 
+int Serializable::maxCount;
+int Serializable::count;
+
 void
 Serializable::nameOut(ostream &os)
 {
@@ -224,6 +227,9 @@ Globals::unserialize(Checkpoint *cp)
 void
 Serializable::serializeAll()
 {
+    if (maxCount && count++ > maxCount)
+        SimExit("Maximum number of checkpoints dropped");
+
     string dir = Checkpoint::dir();
     if (mkdir(dir.c_str(), 0775) == -1 && errno != EEXIST)
             fatal("couldn't mkdir %s\n", dir);
@@ -321,7 +327,8 @@ Param<Counter> serialize_period(&serialParams,
                                 "period to repeat serializations",
                                 0);
 
-
+Param<int> serialize_count(&serialParams, "count",
+                           "maximum number of checkpoints to drop");
 
 SerializeParamContext::SerializeParamContext(const string &section)
     : ParamContext(section), event(NULL)
@@ -342,6 +349,8 @@ SerializeParamContext::checkParams()
 
     if (serialize_cycle > 0)
         Checkpoint::setup(serialize_cycle, serialize_period);
+
+    Serializable::maxCount = serialize_count;
 }
 
 void
index 5df1686658cbdc1a4046deafb11588e60baa9728..de208265eace7795bc75f63ca12bae215cc8fac6 100644 (file)
@@ -119,6 +119,8 @@ class Serializable
     static Serializable *create(Checkpoint *cp,
                                  const std::string &section);
 
+    static int count;
+    static int maxCount;
     static void serializeAll();
     static void unserializeGlobals(Checkpoint *cp);
 };