summaryrefslogtreecommitdiff
path: root/src/python/m5
diff options
context:
space:
mode:
authorKevin Lim <ktlim@umich.edu>2006-07-06 16:06:00 -0400
committerKevin Lim <ktlim@umich.edu>2006-07-06 16:06:00 -0400
commit8ae4f45bc4782b4ab1dc95dbca183e2cd926fc5b (patch)
treead14758015e91929a3095c1f8d9037643e113bde /src/python/m5
parentc8a37ce71514de9362640e8cb18c1744f0e2f83b (diff)
downloadgem5-8ae4f45bc4782b4ab1dc95dbca183e2cd926fc5b.tar.xz
Fixes for draining.
src/cpu/simple/timing.cc: Update for changed return values. src/python/m5/__init__.py: Loop in order to make sure all objects are really drained. Objects may become undrained as other objects become drained (e.g. a bus-bridge has a packet, while a bus is empty, and the first drain() will cause the bus-bridge to give the packet to the bus). The only case we know every object is actually drained is if they all return immediately that they are drained. --HG-- extra : convert_revision : 80057a1d6d30381bd0b67b23549bd202f447c5cb
Diffstat (limited to 'src/python/m5')
-rw-r--r--src/python/m5/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/python/m5/__init__.py b/src/python/m5/__init__.py
index 579785a46..7d35ee8b8 100644
--- a/src/python/m5/__init__.py
+++ b/src/python/m5/__init__.py
@@ -213,14 +213,28 @@ atexit.register(cc_main.doExitCleanup)
# matter since most scripts will probably 'from m5.objects import *'.
import objects
+# This loops until all objects have been fully drained.
def doDrain(root):
+ all_drained = drain(root)
+ while (not all_drained):
+ all_drained = drain(root)
+
+# Tries to drain all objects. Draining might not be completed unless
+# all objects return that they are drained on the first call. This is
+# because as objects drain they may cause other objects to no longer
+# be drained.
+def drain(root):
+ all_drained = False
drain_event = cc_main.createCountedDrain()
unready_objects = root.startDrain(drain_event, True)
# If we've got some objects that can't drain immediately, then simulate
if unready_objects > 0:
drain_event.setCount(unready_objects)
simulate()
+ else:
+ all_drained = True
cc_main.cleanupCountedDrain(drain_event)
+ return all_drained
def resume(root):
root.resume()