From d86bed198ab7fbb16703317aa5414283d761968f Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 13 Apr 2005 09:38:50 -0400 Subject: 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 --- sim/serialize.cc | 11 ++++++++++- sim/serialize.hh | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'sim') 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 serialize_period(&serialParams, "period to repeat serializations", 0); - +Param serialize_count(&serialParams, "count", + "maximum number of checkpoints to drop"); SerializeParamContext::SerializeParamContext(const string §ion) : 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 diff --git a/sim/serialize.hh b/sim/serialize.hh index 5df168665..de208265e 100644 --- a/sim/serialize.hh +++ b/sim/serialize.hh @@ -119,6 +119,8 @@ class Serializable static Serializable *create(Checkpoint *cp, const std::string §ion); + static int count; + static int maxCount; static void serializeAll(); static void unserializeGlobals(Checkpoint *cp); }; -- cgit v1.2.3