summaryrefslogtreecommitdiff
path: root/src/sim/drain.hh
diff options
context:
space:
mode:
authorAndreas Sandberg <andreas.sandberg@arm.com>2017-03-28 13:50:06 +0000
committerAndreas Sandberg <andreas.sandberg@arm.com>2017-04-03 16:38:26 +0000
commit31199bba53493bcfb4d130d8c739d698d21b5dd5 (patch)
treeea3d3a24ee0575f1a7098f7fddb90552c194f353 /src/sim/drain.hh
parent9a13acaa367769c38859342de9bc35aac59a6710 (diff)
downloadgem5-31199bba53493bcfb4d130d8c739d698d21b5dd5.tar.xz
sim: Handle cases where Drainable::resume() creates objects
There are cases where Drainable objects need to create new objects in Drainable::resume(). In such cases, the local drain state will be inherited from the DrainManager. We currently set the state to Running as soon as we start resuming the simulator. This means that new objects are created in the Running state rather than the Drained state, which the resume code assumes. Depending on the traversal order in DrainManager::resume(), this sometimes triggers a panic because the object being resumed is in the wrong state. This change introduces a new drain state, Resuming, that the DrainManager enters as soon as it starts resuming the simulator. Objects that are created while resuming are created in this state. Such objects are then resumed in a subsequent pass over the list of Drainable objects that need to be resumed. Once all objects have been resumed, the simulator enters the Running state. Change-Id: Ieee8645351ffbdec477e9cd2ff86fc795e459617 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Curtis Dunham <curtis.dunham@arm.com> Reviewed-on: https://gem5-review.googlesource.com/2600 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Weiping Liao <weipingliao@google.com>
Diffstat (limited to 'src/sim/drain.hh')
-rw-r--r--src/sim/drain.hh18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/sim/drain.hh b/src/sim/drain.hh
index 663946616..7ff1d6e2a 100644
--- a/src/sim/drain.hh
+++ b/src/sim/drain.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015 ARM Limited
+ * Copyright (c) 2012, 2015, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -58,7 +58,11 @@ class Drainable;
* all objects have entered the Drained state.
*
* Before resuming simulation, the simulator calls resume() to
- * transfer the object to the Running state.
+ * transfer the object to the Running state. This in turn results in a
+ * call to drainResume() for all Drainable objects in the
+ * simulator. New Drainable objects may be created while resuming. In
+ * such cases, the new objects will be created in the Resuming state
+ * and later resumed.
*
* \note Even though the state of an object (visible to the rest of
* the world through Drainable::getState()) could be used to determine
@@ -68,7 +72,8 @@ class Drainable;
enum class DrainState {
Running, /** Running normally */
Draining, /** Draining buffers pending serialization/handover */
- Drained /** Buffers drained, ready for serialization/handover */
+ Drained, /** Buffers drained, ready for serialization/handover */
+ Resuming, /** Transient state while the simulator is resuming */
};
#endif
@@ -153,6 +158,12 @@ class DrainManager
private:
/**
+ * Helper function to check if all Drainable objects are in a
+ * specific state.
+ */
+ bool allInState(DrainState state) const;
+
+ /**
* Thread-safe helper function to get the number of Drainable
* objects in a system.
*/
@@ -261,6 +272,7 @@ class Drainable
switch (_drainState) {
case DrainState::Running:
case DrainState::Drained:
+ case DrainState::Resuming:
return;
case DrainState::Draining:
_drainState = DrainState::Drained;