summaryrefslogtreecommitdiff
path: root/configs
diff options
context:
space:
mode:
authorBrad Beckmann <Brad.Beckmann@amd.com>2011-02-06 22:14:19 -0800
committerBrad Beckmann <Brad.Beckmann@amd.com>2011-02-06 22:14:19 -0800
commit3a388aff697c0487b7ff22aad2abfc051bb01c11 (patch)
treeb9d8cb3f074f24965de35a46215a6baf83c218dd /configs
parentebe563e531d5224ee7aad26767c08e8eba11e4e6 (diff)
downloadgem5-3a388aff697c0487b7ff22aad2abfc051bb01c11.tar.xz
boot: script that creates a checkpoint after Linux boot up
Diffstat (limited to 'configs')
-rw-r--r--configs/boot/hack_back_ckpt.rcS62
1 files changed, 62 insertions, 0 deletions
diff --git a/configs/boot/hack_back_ckpt.rcS b/configs/boot/hack_back_ckpt.rcS
new file mode 100644
index 000000000..4c38a4d32
--- /dev/null
+++ b/configs/boot/hack_back_ckpt.rcS
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#
+# This is a tricky script to understand. When run in M5, it creates
+# a checkpoint after Linux boot up, but before any benchmarks have
+# been run. By playing around with environment variables, we can
+# detect whether the checkpoint has been taken.
+# - If the checkpoint hasn't been taken, the script allows M5 to checkpoint the system,
+# re-read this script into a new tmp file, and re-run it. On the
+# second execution of this script (checkpoint has been taken), the
+# environment variable is already set, so the script will exit the
+# simulation
+# - When we restore the simulation from a checkpoint, we can
+# specify a new script for M5 to execute in the full-system simulation,
+# and it will be executed as if a checkpoint had just been taken.
+#
+# Author:
+# Joel Hestness, hestness@cs.utexas.edu
+# while at AMD Research and Advanced Development Lab
+# Date:
+# 10/5/2010
+#
+
+# Test if the RUNSCRIPT_VAR environment variable is already set
+if [ "${RUNSCRIPT_VAR+set}" != set ]
+then
+ # Signal our future self that it's safe to continue
+ export RUNSCRIPT_VAR=1
+else
+ # We've already executed once, so we should exit
+ /sbin/m5 exit
+fi
+
+# Checkpoint the first execution
+echo "Checkpointing simulation..."
+/sbin/m5 checkpoint
+
+# Test if we previously okayed ourselves to run this script
+if [ "$RUNSCRIPT_VAR" -eq 1 ]
+then
+
+ # Signal our future self not to recurse infinitely
+ export RUNSCRIPT_VAR=2
+
+ # Read the script for the checkpoint restored execution
+ echo "Loading new script..."
+ /sbin/m5 readfile > /tmp/runscript
+ chmod 755 /tmp/runscript
+
+ # Execute the new runscript
+ if [ -s /tmp/runscript ]
+ then
+ exec /tmp/runscript
+ else
+ echo "Script not specified. Dropping into shell..."
+ /bin/bash
+ fi
+
+fi
+
+echo "Fell through script. Exiting..."
+/sbin/m5 exit