diff options
author | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:52 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@ARM.com> | 2013-01-07 13:05:52 -0500 |
commit | 009970f59b86eac6c9a35eeb175dd9e3a3079d13 (patch) | |
tree | 03119f68fd1e03ff753954b63722b916b39f6737 /src/cpu/base.cc | |
parent | 5fb00e1df6b2b7d9db472d0c25765263ed1b839f (diff) | |
download | gem5-009970f59b86eac6c9a35eeb175dd9e3a3079d13.tar.xz |
cpu: Unify the serialization code for all of the CPU models
Cleanup the serialization code for the simple CPUs and the O3 CPU. The
CPU-specific code has been replaced with a (un)serializeThread that
serializes the thread state / context of a specific thread. Assuming
that the thread state class uses the CPU-specific thread state uses
the base thread state serialization code, this allows us to restore a
checkpoint with any of the CPU models.
Diffstat (limited to 'src/cpu/base.cc')
-rw-r--r-- | src/cpu/base.cc | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/cpu/base.cc b/src/cpu/base.cc index 14b5586c8..3e7a6d4b6 100644 --- a/src/cpu/base.cc +++ b/src/cpu/base.cc @@ -524,21 +524,36 @@ BaseCPU::serialize(std::ostream &os) { SERIALIZE_SCALAR(instCnt); - /* Unlike _pid, _taskId is not serialized, as they are dynamically - * assigned unique ids that are only meaningful for the duration of - * a specific run. We will need to serialize the entire taskMap in - * system. */ - SERIALIZE_SCALAR(_pid); - - interrupts->serialize(os); + if (!_switchedOut) { + /* Unlike _pid, _taskId is not serialized, as they are dynamically + * assigned unique ids that are only meaningful for the duration of + * a specific run. We will need to serialize the entire taskMap in + * system. */ + SERIALIZE_SCALAR(_pid); + + interrupts->serialize(os); + + // Serialize the threads, this is done by the CPU implementation. + for (ThreadID i = 0; i < numThreads; ++i) { + nameOut(os, csprintf("%s.xc.%i", name(), i)); + serializeThread(os, i); + } + } } void BaseCPU::unserialize(Checkpoint *cp, const std::string §ion) { UNSERIALIZE_SCALAR(instCnt); - UNSERIALIZE_SCALAR(_pid); - interrupts->unserialize(cp, section); + + if (!_switchedOut) { + UNSERIALIZE_SCALAR(_pid); + interrupts->unserialize(cp, section); + + // Unserialize the threads, this is done by the CPU implementation. + for (ThreadID i = 0; i < numThreads; ++i) + unserializeThread(cp, csprintf("%s.xc.%i", section, i), i); + } } void |