summaryrefslogtreecommitdiff
path: root/src/sim/eventq.cc
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2015-07-07 09:51:04 +0100
committerAndreas Sandberg <andreas.sandberg@arm.com>2015-07-07 09:51:04 +0100
commit888ec455cba4174863be5ed9148aaf093a061101 (patch)
treeccf37fcf4b72fc5de4dcea4ec730aab7f660e572 /src/sim/eventq.cc
parent76cd4393c08b83fa9006ee7bce1fb62457e053c1 (diff)
downloadgem5-888ec455cba4174863be5ed9148aaf093a061101.tar.xz
sim: Fix broken event unserialization
Events expected to be unserialized using an event-specific unserializeEvent call. This call was never actually used, which meant the events relying on it never got unserialized (or scheduled after unserialization). Instead of relying on a custom call, we now use the normal serialization code again. In order to schedule the event correctly, the parrent object is expected to use the EventQueue::checkpointReschedule() call. This happens automatically for events that are serialized using the AutoSerialize mechanism.
Diffstat (limited to 'src/sim/eventq.cc')
-rw-r--r--src/sim/eventq.cc39
1 files changed, 23 insertions, 16 deletions
diff --git a/src/sim/eventq.cc b/src/sim/eventq.cc
index f75ada47c..48664f8e8 100644
--- a/src/sim/eventq.cc
+++ b/src/sim/eventq.cc
@@ -41,7 +41,7 @@
#include "base/misc.hh"
#include "base/trace.hh"
#include "cpu/smt.hh"
-#include "debug/Config.hh"
+#include "debug/Checkpoint.hh"
#include "sim/core.hh"
#include "sim/eventq_impl.hh"
@@ -253,18 +253,12 @@ Event::serialize(CheckpointOut &cp) const
void
Event::unserialize(CheckpointIn &cp)
{
-}
-
-void
-Event::unserializeEvent(CheckpointIn &cp, EventQueue *eventq)
-{
- if (scheduled())
- eventq->deschedule(this);
+ assert(!scheduled());
UNSERIALIZE_SCALAR(_when);
UNSERIALIZE_SCALAR(_priority);
- short _flags;
+ FlagsType _flags;
UNSERIALIZE_SCALAR(_flags);
// Old checkpoints had no concept of the Initialized flag
@@ -280,12 +274,11 @@ Event::unserializeEvent(CheckpointIn &cp, EventQueue *eventq)
// need to see if original event was in a scheduled, unsquashed
// state, but don't want to restore those flags in the current
// object itself (since they aren't immediately true)
- bool wasScheduled = flags.isSet(Scheduled) && !flags.isSet(Squashed);
- flags.clear(Squashed | Scheduled);
-
- if (wasScheduled) {
- DPRINTF(Config, "rescheduling at %d\n", _when);
- eventq->schedule(this, _when);
+ if (flags.isSet(Scheduled) && !flags.isSet(Squashed)) {
+ flags.clear(Squashed | Scheduled);
+ } else {
+ DPRINTF(Checkpoint, "Event '%s' need to be scheduled @%d\n",
+ name(), _when);
}
}
@@ -329,11 +322,25 @@ EventQueue::unserialize(CheckpointIn &cp)
paramIn(cp, csprintf("event%d", i), eventName);
// create the event based on its pointer value
- Serializable::create(cp, eventName);
+ Serializable *obj(Serializable::create(cp, eventName));
+ Event *event(dynamic_cast<Event *>(obj));
+ fatal_if(!event,
+ "Event queue unserialized something that wasn't an event.\n");
+
+ checkpointReschedule(event);
}
}
void
+EventQueue::checkpointReschedule(Event *event)
+{
+ // It's safe to call insert() directly here since this method
+ // should only be called when restoring from a checkpoint (which
+ // happens before thread creation).
+ if (event->flags.isSet(Event::Scheduled))
+ insert(event);
+}
+void
EventQueue::dump() const
{
cprintf("============================================================\n");