summaryrefslogtreecommitdiff
path: root/sim/serialize.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sim/serialize.cc')
-rw-r--r--sim/serialize.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/sim/serialize.cc b/sim/serialize.cc
index 846d191e0..1976e6b3c 100644
--- a/sim/serialize.cc
+++ b/sim/serialize.cc
@@ -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