simulate.py (9326:96ae1c545fb5) simulate.py (9342:6fec8f26e56d)
1# Copyright (c) 2012 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

164 all_drained = drain(root)
165
166# Tries to drain all objects. Draining might not be completed unless
167# all objects return that they are drained on the first call. This is
168# because as objects drain they may cause other objects to no longer
169# be drained.
170def drain(root):
171 all_drained = False
1# Copyright (c) 2012 ARM Limited
2# All rights reserved.
3#
4# The license below extends only to copyright in the software and shall
5# not be construed as granting a license to any other intellectual
6# property including but not limited to intellectual property relating
7# to a hardware implementation of the functionality of the software
8# licensed hereunder. You may use the software subject to the license

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

164 all_drained = drain(root)
165
166# Tries to drain all objects. Draining might not be completed unless
167# all objects return that they are drained on the first call. This is
168# because as objects drain they may cause other objects to no longer
169# be drained.
170def drain(root):
171 all_drained = False
172 drain_event = internal.event.createCountedDrain()
173 unready_objs = sum(obj.drain(drain_event) for obj in root.descendants())
172 dm = internal.drain.createDrainManager()
173 unready_objs = sum(obj.drain(dm) for obj in root.descendants())
174 # If we've got some objects that can't drain immediately, then simulate
175 if unready_objs > 0:
174 # If we've got some objects that can't drain immediately, then simulate
175 if unready_objs > 0:
176 drain_event.setCount(unready_objs)
176 dm.setCount(unready_objs)
177 simulate()
178 else:
179 all_drained = True
177 simulate()
178 else:
179 all_drained = True
180 internal.event.cleanupCountedDrain(drain_event)
180 internal.drain.cleanupDrainManager(dm)
181 return all_drained
182
183def resume(root):
181 return all_drained
182
183def resume(root):
184 for obj in root.descendants(): obj.resume()
184 for obj in root.descendants(): obj.drainResume()
185
186def checkpoint(dir):
187 root = objects.Root.getInstance()
188 if not isinstance(root, objects.Root):
189 raise TypeError, "Checkpoint must be called on a root object."
190 doDrain(root)
191 print "Writing checkpoint"
192 internal.core.serializeAll(dir)

--- 43 unchanged lines hidden ---
185
186def checkpoint(dir):
187 root = objects.Root.getInstance()
188 if not isinstance(root, objects.Root):
189 raise TypeError, "Checkpoint must be called on a root object."
190 doDrain(root)
191 print "Writing checkpoint"
192 internal.core.serializeAll(dir)

--- 43 unchanged lines hidden ---