+ else
+ PANIC ("unknown option `%s' (use -h for help)", name);
+ }
+
+ /* Initialize the random number generator based on the system
+ time. This has no effect if an "-rs" option was specified.
+
+ When running under Bochs, this is not enough by itself to
+ get a good seed value, because the pintos script sets the
+ initial time to a predictable value, not to the local time,
+ for reproducibility. To fix this, give the "-r" option to
+ the pintos script to request real-time execution. */
+ random_init (rtc_get_time ());
+
+ return argv;
+}
+
+/* Runs the task specified in ARGV[1]. */
+static void
+run_task (char **argv)
+{
+ const char *task = argv[1];
+
+ printf ("Executing '%s':\n", task);
+#ifdef USERPROG
+ process_wait (process_execute (task));
+#else
+ run_test (task);
+#endif
+ printf ("Execution of '%s' complete.\n", task);
+}
+
+/* Executes all of the actions specified in ARGV[]
+ up to the null pointer sentinel. */
+static void
+run_actions (char **argv)
+{
+ /* An action. */
+ struct action
+ {
+ char *name; /* Action name. */
+ int argc; /* # of args, including action name. */
+ void (*function) (char **argv); /* Function to execute action. */
+ };
+
+ /* Table of supported actions. */
+ static const struct action actions[] =
+ {
+ {"run", 2, run_task},