fix the checkpoint bug
authorAli Saidi <saidi@eecs.umich.edu>
Fri, 12 May 2006 21:47:23 +0000 (17:47 -0400)
committerAli Saidi <saidi@eecs.umich.edu>
Fri, 12 May 2006 21:47:23 +0000 (17:47 -0400)
--HG--
extra : convert_revision : 1ccae3282737d70b14ff86c8647e2e662a42c3bc

dev/sinic.cc
sim/serialize.cc
sim/serialize.hh

index d19ef268fbb22c75314eff1a7b29c1794bb138a5..0853717bacd74ccf31481d5a9bc602436db0698b 100644 (file)
@@ -1448,6 +1448,8 @@ Base::unserialize(Checkpoint *cp, const std::string &section)
 void
 Device::serialize(ostream &os)
 {
+    int count;
+
     // Serialize the PciDev base class
     Base::serialize(os);
 
index ec72414985c9f1c65a75bbf0a2c68df732fe1089..c4ef124bb5723490a644a56bcacfe4cc71fa78e2 100644 (file)
@@ -51,8 +51,9 @@
 
 using namespace std;
 
-int Serializable::maxCount = 0;
-int Serializable::count = 0;
+int Serializable::ckptMaxCount = 0;
+int Serializable::ckptCount = 0;
+int Serializable::ckptPrevCount = -1;
 
 void
 Serializable::nameOut(ostream &os)
@@ -241,8 +242,11 @@ Serializable::serializeAll()
     globals.serialize(outstream);
     SimObject::serializeAll(outstream);
 
-    if (maxCount && ++count >= maxCount)
+    assert(Serializable::ckptPrevCount + 1 == Serializable::ckptCount);
+    Serializable::ckptPrevCount++;
+    if (ckptMaxCount && ++ckptCount >= ckptMaxCount)
         SimExit(curTick + 1, "Maximum number of checkpoints dropped");
+
 }
 
 
@@ -352,7 +356,7 @@ SerializeParamContext::checkParams()
     if (serialize_cycle > 0)
         Checkpoint::setup(serialize_cycle, serialize_period);
 
-    Serializable::maxCount = serialize_count;
+    Serializable::ckptMaxCount = serialize_count;
 }
 
 void
index bc82bf9b81f9a7237aaf0ad1e94d7ed840cfada5..d8f5f8fc508fd53e07ad1d7984b87134e70f61d6 100644 (file)
@@ -119,8 +119,9 @@ class Serializable
     static Serializable *create(Checkpoint *cp,
                                  const std::string &section);
 
-    static int count;
-    static int maxCount;
+    static int ckptCount;
+    static int ckptMaxCount;
+    static int ckptPrevCount;
     static void serializeAll();
     static void unserializeGlobals(Checkpoint *cp);
 };