our ($sim);
our ($debug);
our ($vga);
-our ($jitter);
+our ($jitter, $realtime);
use Getopt::Long qw(:config require_order bundling);
GetOptions ("sim=s" => sub { set_sim (@_) },
"run|get|put|make-disk" => \&cmd_option,
"m|memory=i" => \$mem,
- "j|jitter=i" => \$jitter,
+ "j|jitter=i" => sub { set_jitter (@_) },
+ "r|realtime" => sub { set_realtime () },
"v|no-vga" => sub { set_vga ('none'); },
"s|no-serial" => sub { $serial_out = 0; },
$vga = $new_vga;
}
+sub set_jitter {
+ my ($new_jitter) = @_;
+ die "--realtime conflicts with --jitter\n" if defined $realtime;
+ die "different --jitter already defined\n"
+ if defined $jitter && $jitter != $new_jitter;
+ $jitter = $new_jitter;
+}
+
+sub set_realtime {
+ die "--realtime conflicts with --jitter\n" if defined $jitter;
+ $realtime = 1;
+}
+
sub cmd_option {
# Force an end to option processing, as with --.
die ("!FINISH");
# Create scratch disk from file.
die "$hostfn: $!\n" if ! -e $hostfn;
my ($size) = -s _;
- copy_pad ($hostfn, "scratch.dsk", 512);
+ if ($size) {
+ copy_pad ($hostfn, "scratch.dsk", 512);
+ } else {
+ open (SCRATCH, ">scratch.dsk") or die "scratch.dsk: create: $!\n";
+ syswrite (SCRATCH, "\0" x 512);
+ close (SCRATCH);
+ }
# Do copy.
my (@cmd) = ("-ci", $guestfn, $size, "-q");
print " -t, --terminal Display VGA in terminal (Bochs only)\n";
print "VM options:\n";
print " -j SEED Randomize timer interrupts (Bochs only)\n";
+ print " -r, --realtime Use realistic, but not reproducible, timings\n";
print " -m, --mem=MB Run VM with MB megabytes of physical memory\n";
print "Disk options:\n";
print " --os-disk=DISK Set OS disk file (default: os.dsk)\n";
undef $disks[$i] if ! -e $disks[$i];
}
+ my ($project) = `pwd` =~ /\b(threads|userprog|vm|filesys)\b/;
+ if (($project eq 'userprog' || $project eq 'vm' || $project eq 'filesys')
+ && !defined $disks[1]) {
+ print STDERR "warning: it looks like you're running the $project project, "
+ . "but no file system disk is present\n";
+ }
+ if ($project eq 'vm' && !defined $disks[3]) {
+ print STDERR "warning: it looks like you're running the $project project, "
+ . "but no swap disk is present\n";
+ }
+
write_cmd_line ($disks[0], @_);
if ($sim eq 'bochs') {
print BOCHSRC bochs_disk_line ("ata1-slave", $disks[3]);
print BOCHSRC "boot: c\n";
print BOCHSRC "ips: 1000000\n";
- print BOCHSRC "clock: sync=none, time0=0\n";
+ if (!$realtime) {
+ print BOCHSRC "clock: sync=none, time0=0\n";
+ } else {
+ print BOCHSRC "clock: sync=realtime, time0=0\n";
+ }
print BOCHSRC "megs: $mem\n";
print BOCHSRC "log: bochsout.txt\n";
if ($vga ne 'terminal') {