summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/python/m5/simulate.py4
-rw-r--r--src/sim/drain.hh14
2 files changed, 18 insertions, 0 deletions
diff --git a/src/python/m5/simulate.py b/src/python/m5/simulate.py
index 66344bc79..d89629d2d 100644
--- a/src/python/m5/simulate.py
+++ b/src/python/m5/simulate.py
@@ -308,4 +308,8 @@ def switchCpus(system, cpuList, verbose=True):
for old_cpu, new_cpu in cpuList:
new_cpu.takeOverFrom(old_cpu)
+def notifyFork(root):
+ for obj in root.descendants():
+ obj.notifyFork()
+
from internal.core import disableAllListeners
diff --git a/src/sim/drain.hh b/src/sim/drain.hh
index 31dbc97af..370217bd6 100644
--- a/src/sim/drain.hh
+++ b/src/sim/drain.hh
@@ -275,6 +275,20 @@ class Drainable
/** Return the current drain state of an object. */
DrainState drainState() const { return _drainState; }
+ /**
+ * Notify a child process of a fork.
+ *
+ * When calling fork in gem5, we need to ensure that resources
+ * shared between the parent and the child are consistent. This
+ * method is intended to be overloaded to handle that. For
+ * example, an object could use this method to re-open input files
+ * to get a separate file description with a private file offset.
+ *
+ * This method is only called in the child of the fork. The call
+ * takes place in a drained system.
+ */
+ virtual void notifyFork() {};
+
private:
/** DrainManager interface to request a drain operation */
DrainState dmDrain();