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
This commit is contained in:
parent
be7152b552
commit
d86bed198a
|
@ -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 §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
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue