simulate.py (11360:40be59176869) simulate.py (11362:04966a265ff9)
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

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

307
308 for old_cpu, new_cpu in cpuList:
309 new_cpu.takeOverFrom(old_cpu)
310
311def notifyFork(root):
312 for obj in root.descendants():
313 obj.notifyFork()
314
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

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

307
308 for old_cpu, new_cpu in cpuList:
309 new_cpu.takeOverFrom(old_cpu)
310
311def notifyFork(root):
312 for obj in root.descendants():
313 obj.notifyFork()
314
315fork_count = 0
316def fork(simout="%(parent)s.f%(fork_seq)i"):
317 """Fork the simulator.
318
319 This function forks the simulator. After forking the simulator,
320 the child process gets its output files redirected to a new output
321 directory. The default name of the output directory is the same as
322 the parent with the suffix ".fN" added where N is the fork
323 sequence number. The name of the output directory can be
324 overridden using the simout keyword argument.
325
326 Output file formatting dictionary:
327 parent -- Path to the parent process's output directory.
328 fork_seq -- Fork sequence number.
329 pid -- PID of the child process.
330
331 Keyword Arguments:
332 simout -- New simulation output directory.
333
334 Return Value:
335 pid of the child process or 0 if running in the child.
336 """
337 from m5 import options
338 global fork_count
339
340 if not internal.core.listenersDisabled():
341 raise RuntimeError, "Can not fork a simulator with listeners enabled"
342
343 drain()
344
345 try:
346 pid = os.fork()
347 except OSError, e:
348 raise e
349
350 if pid == 0:
351 # In child, notify objects of the fork
352 root = objects.Root.getInstance()
353 notifyFork(root)
354 # Setup a new output directory
355 parent = options.outdir
356 options.outdir = simout % {
357 "parent" : parent,
358 "fork_seq" : fork_count,
359 "pid" : os.getpid(),
360 }
361 core.setOutputDir(options.outdir)
362 else:
363 fork_count += 1
364
365 return pid
366
315from internal.core import disableAllListeners
367from internal.core import disableAllListeners
368from internal.core import listenersDisabled