__init__.py (2839:d5dd8a3cdea0) __init__.py (2860:843426871cbc)
1# Copyright (c) 2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 199 unchanged lines hidden (view full) ---

208# register our C++ exit callback function with Python
209atexit.register(cc_main.doExitCleanup)
210
211# This import allows user scripts to reference 'm5.objects.Foo' after
212# just doing an 'import m5' (without an 'import m5.objects'). May not
213# matter since most scripts will probably 'from m5.objects import *'.
214import objects
215
1# Copyright (c) 2005 The Regents of The University of Michigan
2# All rights reserved.
3#
4# Redistribution and use in source and binary forms, with or without
5# modification, are permitted provided that the following conditions are
6# met: redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer;
8# redistributions in binary form must reproduce the above copyright

--- 199 unchanged lines hidden (view full) ---

208# register our C++ exit callback function with Python
209atexit.register(cc_main.doExitCleanup)
210
211# This import allows user scripts to reference 'm5.objects.Foo' after
212# just doing an 'import m5' (without an 'import m5.objects'). May not
213# matter since most scripts will probably 'from m5.objects import *'.
214import objects
215
216# This loops until all objects have been fully drained.
216def doDrain(root):
217def doDrain(root):
218 all_drained = drain(root)
219 while (not all_drained):
220 all_drained = drain(root)
221
222# Tries to drain all objects. Draining might not be completed unless
223# all objects return that they are drained on the first call. This is
224# because as objects drain they may cause other objects to no longer
225# be drained.
226def drain(root):
227 all_drained = False
217 drain_event = cc_main.createCountedDrain()
218 unready_objects = root.startDrain(drain_event, True)
219 # If we've got some objects that can't drain immediately, then simulate
220 if unready_objects > 0:
221 drain_event.setCount(unready_objects)
222 simulate()
228 drain_event = cc_main.createCountedDrain()
229 unready_objects = root.startDrain(drain_event, True)
230 # If we've got some objects that can't drain immediately, then simulate
231 if unready_objects > 0:
232 drain_event.setCount(unready_objects)
233 simulate()
234 else:
235 all_drained = True
223 cc_main.cleanupCountedDrain(drain_event)
236 cc_main.cleanupCountedDrain(drain_event)
237 return all_drained
224
225def resume(root):
226 root.resume()
227
228def checkpoint(root):
229 if not isinstance(root, objects.Root):
230 raise TypeError, "Object is not a root object. Checkpoint must be called on a root object."
231 doDrain(root)

--- 61 unchanged lines hidden ---
238
239def resume(root):
240 root.resume()
241
242def checkpoint(root):
243 if not isinstance(root, objects.Root):
244 raise TypeError, "Object is not a root object. Checkpoint must be called on a root object."
245 doDrain(root)

--- 61 unchanged lines hidden ---