changeset 40be59176869 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=40be59176869
description:
        sim: Add support for notifying Drainable objects of a fork

        When forking a gem5 process, some objects need to clean up resources
        (mainly file descriptions) shared between the child and the parent of
        the fork. This changeset adds the notifyFork() method to Drainable,
        which is called in the child process.

        Signed-off-by: Andreas Sandberg <[email protected]>
        [[email protected]: Rebased patches onto a newer gem5 version]
        Signed-off-by: Sascha Bischoff <[email protected]>
        Signed-off-by: Andreas Sandberg <[email protected]>

diffstat:

 src/python/m5/simulate.py |   4 ++++
 src/sim/drain.hh          |  14 ++++++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diffs (36 lines):

diff -r b0b976a1ceda -r 40be59176869 src/python/m5/simulate.py
--- a/src/python/m5/simulate.py Fri Nov 27 14:41:59 2015 +0000
+++ b/src/python/m5/simulate.py Thu Nov 26 10:03:43 2015 +0000
@@ -308,4 +308,8 @@
     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 -r b0b976a1ceda -r 40be59176869 src/sim/drain.hh
--- a/src/sim/drain.hh  Fri Nov 27 14:41:59 2015 +0000
+++ b/src/sim/drain.hh  Thu Nov 26 10:03:43 2015 +0000
@@ -275,6 +275,20 @@
     /** 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();
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to