summaryrefslogtreecommitdiff
path: root/sim/serialize.cc
diff options
context:
space:
mode:
authorNathan Binkert <binkertn@umich.edu>2005-04-13 09:38:50 -0400
committerNathan Binkert <binkertn@umich.edu>2005-04-13 09:38:50 -0400
commitd86bed198ab7fbb16703317aa5414283d761968f (patch)
tree97f486913e675e2cb52d7d08aac0cab530d1b8db /sim/serialize.cc
parentbe7152b5524a02bb529f095a0c0e15caece189e5 (diff)
downloadgem5-d86bed198ab7fbb16703317aa5414283d761968f.tar.xz
Add support to limit the number of checkpoints dropped.
sim/serialize.hh: Add variables to keep track of the number of checkpoints dropped and maximum allowed. --HG-- extra : convert_revision : 32241b90c58def6958ec84c53cc2cca996007506
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