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

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

34# import the SWIG-wrapped main C++ functions
35import internal
36import core
37import stats
38from main import options
39import SimObject
40import ticks
41import objects
42from util import fatal
43
44# define a MaxTick parameter
45MaxTick = 2**63 - 1
46
47# The final hook to generate .ini files. Called from the user script
48# once the config is built.
48def instantiate(root):
49def instantiate():
50 root = objects.Root.getInstance()
51
52 if not root:
53 fatal("Need to instantiate Root() before calling instantiate()")
54
55 # we need to fix the global frequency
56 ticks.fixGlobalFrequency()
57
58 root.unproxy_all()
59
60 if options.dump_config:
61 ini_file = file(os.path.join(options.outdir, options.dump_config), 'w')
62 root.print_ini(ini_file)

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

137 else:
138 all_drained = True
139 internal.event.cleanupCountedDrain(drain_event)
140 return all_drained
141
142def resume(root):
143 root.resume()
144
139def checkpoint(root, dir):
145def checkpoint(dir):
146 root = objects.Root.getInstance()
147 if not isinstance(root, objects.Root):
148 raise TypeError, "Checkpoint must be called on a root object."
149 doDrain(root)
150 print "Writing checkpoint"
151 internal.core.serializeAll(dir)
152 resume(root)
153
147def restoreCheckpoint(root, dir):
154def restoreCheckpoint(dir):
155 root = objects.Root.getInstance()
156 print "Restoring from checkpoint"
157 internal.core.unserializeAll(dir)
158 need_resume.append(root)
159 stats.reset()
160
161def changeToAtomic(system):
162 if not isinstance(system, (objects.Root, objects.System)):
163 raise TypeError, "Parameter of type '%s'. Must be type %s or %s." % \

--- 38 unchanged lines hidden ---