-sub mlfqs_stats {
- my (@output) = @_;
- my (%stats) = ("io" => {}, "cpu" => {}, "mix" => {});
- my (%map) = ("CPU intensive" => "cpu",
- "IO intensive" => "io",
- "Alternating IO/CPU" => "mix");
- local ($_);
- foreach (@output) {
- my ($thread, $pri) = /^([A-Za-z\/ ]+): (\d+)$/ or next;
- my ($t) = $map{$thread} or next;
-
- my ($s) = $stats{$t};
- $$s{"n"}++;
- $$s{"sum"} += $pri;
- $$s{"sum2"} += $pri * $pri;
- $$s{"min"} = $pri if !defined ($$s{"min"}) || $pri < $$s{"min"};
- $$s{"max"} = $pri if !defined ($$s{"max"}) || $pri > $$s{"max"};
- }
-
- my ($details) = "";
- for my $t (keys %stats) {
- my ($s) = $stats{$t};
- $details .= "$t: n=$$s{'n'}, min=$$s{'min'}, max=$$s{'max'}, avg=" . int ($$s{'sum'} / $$s{'n'}) . "\n";
- }
- $details{$test} = $details;
- die "MLFQS\n";
-}
-\f
-sub verify_common {
- my (@output) = @_;
-
- my (@assertion) = grep (/PANIC/, @output);
- if (@assertion != 0) {
- my ($details) = "Kernel panic:\n $assertion[0]\n";
-
- my (@stack_line) = grep (/Call stack:/, @output);
- if (@stack_line != 0) {
- get_binaries ();
- $details .= " $stack_line[0]\n\n";
- $details .= "Translation of backtrace:\n";
- my ($addrs) = $stack_line[0] =~ /Call stack:((?: 0x[0-9a-f]+)+)/;
-
- my ($A2L);
- if (`uname -m`
- =~ /i.86|pentium.*|[pk][56]|nexgen|viac3|6x86|athlon.*/) {
- $A2L = "addr2line";
- } else {
- $A2L = "i386-elf-addr2line";
- }
- open (A2L, "$A2L -fe pintos/src/threads/build/kernel.o $addrs|");
- while (my $function = <A2L>) {
- my ($line) = <A2L>;
- chomp $function;
- chomp $line;
- $details .= " $function ($line)\n";
- }
- }
- $extra{$test} = $details;
- die "Kernel panic. Details at end of file.\n"
- }
-
- die "No output at all\n" if @output == 0;
- die "Didn't start up properly: no \"Pintos booting\" startup message\n"
- if !grep (/Pintos booting with.*kB RAM\.\.\./, @output);
- die "Didn't start up properly: no \"Boot complete\" startup message\n"
- if !grep (/Boot complete/, @output);
- die "Didn't shut down properly: no \"Timer: # ticks\" shutdown message\n"
- if !grep (/Timer: \d+ ticks/, @output);
- die "Didn't shut down properly: no \"Powering off\" shutdown message\n"
- if !grep (/Powering off/, @output);
-}
-
-sub get_binaries {
- if (!files_equal ("pintos/src/threads/test.c", test_source ($test))
- || !file_contains ("pintos/src/constants.h",
- test_constants ($test))) {
- unlink ("output/$test.run.out")
- or die "output/$test.run.out: unlink: $!\n";
- die "rerun\n";
- }