4 # This is a tricky script to understand. When run in M5, it creates
5 # a checkpoint after Linux boot up, but before any benchmarks have
6 # been run. By playing around with environment variables, we can
7 # detect whether the checkpoint has been taken.
8 # - If the checkpoint hasn't been taken, the script allows M5 to checkpoint the system,
9 # re-read this script into a new tmp file, and re-run it. On the
10 # second execution of this script (checkpoint has been taken), the
11 # environment variable is already set, so the script will exit the
13 # - When we restore the simulation from a checkpoint, we can
14 # specify a new script for M5 to execute in the full-system simulation,
15 # and it will be executed as if a checkpoint had just been taken.
18 # Joel Hestness, hestness@cs.utexas.edu
19 # while at AMD Research and Advanced Development Lab
24 # Test if the RUNSCRIPT_VAR environment variable is already set
25 if [ "${RUNSCRIPT_VAR+set}" != set ]
27 # Signal our future self that it's safe to continue
28 export RUNSCRIPT_VAR
=1
30 # We've already executed once, so we should exit
34 # Checkpoint the first execution
35 echo "Checkpointing simulation..."
38 # Test if we previously okayed ourselves to run this script
39 if [ "$RUNSCRIPT_VAR" -eq 1 ]
42 # Signal our future self not to recurse infinitely
43 export RUNSCRIPT_VAR
=2
45 # Read the script for the checkpoint restored execution
46 echo "Loading new script..."
47 /sbin
/m5 readfile
> /tmp
/runscript
48 chmod 755 /tmp
/runscript
50 # Execute the new runscript
51 if [ -s /tmp
/runscript
]
55 echo "Script not specified. Dropping into shell..."
61 echo "Fell through script. Exiting..."