First pass at a serializer object, may need to work on naming of object and functions:

Intended Use:
A SimObject will call the serializer when it needs the state to be serializable (i.e. switchCPUs, checkpoint, switch memory access model).  It will call the requestSeialization() function.
The Serializer will signal all the objects in its list to drain their state via the SimObject method drain().  Drain() has a default implementation to just signal done.
When each object is drained it will signal the Serializer that it has drained via the signalDrained() function.
The Serializer will collect these signals, when all have drained it will signal the initial requestor via serializationComplete() method in the SimObject.
Once that object is done, it will signal the Serializer to resumeExecution().
The Serializer will signal all the objects in its list to resume via the resume() method on the SimObject.

SConscript:
    Add serializer object to build list
sim/sim_object.cc:
    Add default behavior for drain (just signal finished, must be overided if you really must drain something)
sim/sim_object.hh:
    Add functions for serializer

--HG--
extra : convert_revision : 15aa2d1b42010c2d703bef9114c11d079c216170
This commit is contained in:
Ron Dreslinski 2006-05-11 17:24:15 -04:00
parent 80dee53b04
commit 5cfff7d5bb
3 changed files with 17 additions and 0 deletions

View file

@ -62,6 +62,7 @@ base_sources = Split('''
base/range.cc
base/random.cc
base/sat_counter.cc
base/serializer.cc
base/socket.cc
base/statistics.cc
base/str.cc

View file

@ -34,6 +34,7 @@
#include "base/misc.hh"
#include "base/trace.hh"
#include "base/stats/events.hh"
#include "base/serializer.hh"
#include "sim/configfile.hh"
#include "sim/host.hh"
#include "sim/sim_object.hh"
@ -248,4 +249,10 @@ SimObject::recordEvent(const std::string &stat)
Stats::recordEvent(stat);
}
void
SimObject::drain(Serializer *serializer)
{
serializer->signalDrained();
}
DEFINE_SIM_OBJECT_CLASS_NAME("SimObject", SimObject)

View file

@ -41,6 +41,8 @@
#include "sim/serialize.hh"
#include "sim/startup.hh"
class Serializer;
/*
* Abstract superclass for simulation objects. Represents things that
* correspond to physical components and can be specified via the
@ -96,6 +98,13 @@ class SimObject : public Serializable, protected StartupCallback
// static: call nameOut() & serialize() on all SimObjects
static void serializeAll(std::ostream &);
// Methods to drain objects in order to take checkpoints
// Or switch from timing -> atomic memory model
virtual void drain(Serializer *serializer);
virtual void resume() { return;} ;
virtual void serializationComplete()
{ assert(0 && "Unimplemented"); };
#ifdef DEBUG
public:
bool doDebugBreak;