From: Ben Pfaff Date: Fri, 11 Feb 2005 05:13:08 +0000 (+0000) Subject: Apply appropriate changes from main branch to bring win0405-branch up X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=601d95be13aa18bfdea51930f86cccdde1c01f5e Apply appropriate changes from main branch to bring win0405-branch up to date. --- diff --git a/doc/threads.texi b/doc/threads.texi index 1905707..a79e474 100644 --- a/doc/threads.texi +++ b/doc/threads.texi @@ -157,9 +157,9 @@ the kernel. Basic interrupt handling and functions for turning interrupts on and off. -@item intr-stubs.S +@item intr-stubs.pl @itemx intr-stubs.h -Assembly code for low-level interrupt handling. +A Perl program that outputs assembly for low-level interrupt handling. @item synch.c @itemx synch.h @@ -502,6 +502,10 @@ Write test code that demonstrates the cases your join works for. Be careful to program this function correctly. You will need its functionality for project 2. +Once you've implemented @func{thread_join}, define +@code{THREAD_JOIN_IMPLEMENTED} in @file{constants.h}. +@xref{Conditional Compilation}, for more information. + @node Problem 1-3 Priority Scheduling @section Problem 1-3: Priority Scheduling diff --git a/doc/tour.texi b/doc/tour.texi index d1147dd..39483a3 100644 --- a/doc/tour.texi +++ b/doc/tour.texi @@ -782,7 +782,11 @@ In Pintos, @func{intr_init} in @file{threads/interrupt.c} sets up the IDT so that each entry points to a unique entry point in @file{threads/intr-stubs.S} named @func{intr@var{NN}_stub}, where @var{NN} is the interrupt number in -hexadecimal. Because the CPU doesn't give +hexadecimal.@footnote{@file{threads/intr-stubs.S} is so repetitive +that it is actually generated by a Perl script, +@file{threads/intr-stubs.pl}. Thus, you will actually find +@file{threads/intr-stubs.S} in your @file{threads/build/threads} +directory, not in plain @file{threads}.} Because the CPU doesn't give us any other way to find out the interrupt number, this entry point pushes the interrupt number on the stack. Then it jumps to @func{intr_entry}, which pushes all the registers that the processor diff --git a/doc/vm.texi b/doc/vm.texi index 6eff492..4325b13 100644 --- a/doc/vm.texi +++ b/doc/vm.texi @@ -38,6 +38,9 @@ introduced in this project. You will continue to handle Pintos disks and file systems the same way you did in the previous assignment (@pxref{Using the File System}). +Your submission should define @code{THREAD_JOIN_IMPLEMENTED} in +@file{constants.h} (@pxref{Conditional Compilation}). + @menu * VM Design:: * Page Faults:: diff --git a/grading/lib/Pintos/Grading.pm b/grading/lib/Pintos/Grading.pm index 6a21d52..463d475 100644 --- a/grading/lib/Pintos/Grading.pm +++ b/grading/lib/Pintos/Grading.pm @@ -138,9 +138,10 @@ sub extract_sources { LOG => $stem, DIE => "applying patch $stem failed\n"); } - # Install default pintos/src/constants.h (which is empty). + # Install default pintos/src/constants.h. open (CONSTANTS, ">pintos/src/constants.h") or die "constants.h: create: $!\n"; + print CONSTANTS "#define THREAD_JOIN_IMPLEMENTED 1\n"; close CONSTANTS; } diff --git a/grading/threads/run-tests b/grading/threads/run-tests index 0852f6f..dd2e7d3 100755 --- a/grading/threads/run-tests +++ b/grading/threads/run-tests @@ -56,6 +56,7 @@ die "Don't know how to '$action'"; sub run_test { # Change constants.h if necessary. my ($defines) = $test ne 'mlfqs-on' ? "" : "#define MLFQS 1\n"; + $defines .= "#define THREAD_JOIN_IMPLEMENTED 1\n"; if ($defines ne snarf ("pintos/src/constants.h")) { open (CONSTANTS, ">pintos/src/constants.h"); print CONSTANTS $defines; diff --git a/src/threads/interrupt.h b/src/threads/interrupt.h index b805671..99abf8e 100644 --- a/src/threads/interrupt.h +++ b/src/threads/interrupt.h @@ -19,7 +19,7 @@ enum intr_level intr_disable (void); /* Interrupt stack frame. */ struct intr_frame { - /* Pushed by intr_entry in intr-stubs.S. + /* Pushed by intr_entry in intr-stubs.S (see intr-stubs.pl). These are the interrupted task's saved registers. */ uint32_t edi; /* Saved EDI. */ uint32_t esi; /* Saved ESI. */ @@ -34,18 +34,13 @@ struct intr_frame uint16_t es, :16; /* Saved ES segment register. */ uint16_t ds, :16; /* Saved DS segment register. */ - /* Pushed by intrNN_stub in intr-stubs.S. */ + /* Pushed by intrXX_stub in intr-stubs.S (see intr-stubs.pl). */ uint32_t vec_no; /* Interrupt vector number. */ /* Sometimes pushed by the CPU, - otherwise for consistency pushed as 0 by intrNN_stub. - The CPU puts it just under `eip', but we move it here. */ + otherwise for consistency pushed as 0 by intrXX_stub. */ uint32_t error_code; /* Error code. */ - /* Pushed by intrNN_stub in intr-stubs.S. - This frame pointer eases interpretation of backtraces. */ - void *frame_pointer; /* Saved EBP (frame pointer). */ - /* Pushed by the CPU. These are the interrupted task's saved registers. */ void (*eip) (void); /* Next instruction to execute. */ diff --git a/src/threads/intr-stubs.pl b/src/threads/intr-stubs.pl new file mode 100755 index 0000000..75cde7b --- /dev/null +++ b/src/threads/intr-stubs.pl @@ -0,0 +1,66 @@ +#! /usr/bin/perl + +print <<'EOF'; +#include "threads/loader.h" + + .data + .intel_syntax noprefix +.globl intr_stubs +intr_stubs: +EOF + +for $i (0...255) { + $x = sprintf ("%02x", $i); + print "\t.long intr${x}_stub\n"; +} + +print <<'EOF'; + + .text +EOF + +for $i (0...255) { + $x = sprintf ("%02x", $i); + print ".globl intr${x}_stub\n"; + print "intr${x}_stub:\n"; + print "\tpush 0\n" + if ($i != 8 && $i != 10 && $i != 11 + && $i != 13 && $i != 14 && $i != 17); + print "\tpush 0x$x\n"; + print "\tjmp intr_entry\n"; +} + +print <<'EOF'; +intr_entry: + # Save caller's registers. + push ds + push es + push fs + push gs + pusha + + # Set up kernel environment. + cld + mov eax, SEL_KDSEG + mov ds, eax + mov es, eax + + # Call interrupt handler. + push esp +.globl intr_handler + call intr_handler + add esp, 4 + +.globl intr_exit +intr_exit: + # Restore caller's registers. + popa + pop gs + pop fs + pop es + pop ds + add esp, 8 + + # Return to caller. + iret +EOF diff --git a/src/threads/thread.c b/src/threads/thread.c index ae92e1d..1e5a7d2 100644 --- a/src/threads/thread.c +++ b/src/threads/thread.c @@ -273,31 +273,6 @@ thread_yield (void) schedule (); intr_set_level (old_level); } - -/* Waits for the thread with the specified TID to terminate. If - TID has already terminated or TID does not refer to an - immediate child of the current thread, returns immediately. - - This function will be implemented in problem 1-2. For now, it - does nothing. */ -void -thread_join (tid_t child_tid UNUSED) -{ -} - -/* Sets the current thread's priority to NEW_PRIORITY. */ -void -thread_set_priority (int new_priority) -{ - thread_current ()->priority = new_priority; -} - -/* Returns the current thread's priority. */ -int -thread_get_priority (void) -{ - return thread_current ()->priority; -} /* Idle thread. Executes when no other thread is ready to run. */ static void diff --git a/tests/Makefile b/tests/Makefile index efea7a5..4bdd597 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -7,6 +7,9 @@ all: check: $(MAKE) -C .. distclean + $(MAKE) check-noclean + +check-noclean: for d in $(TESTS); do $(MAKE) $$d || exit 1; done @echo All tests passed. @@ -91,6 +94,7 @@ userprog:: $(prep-grading) $(mk-sandbox) $(apply-patch) ../solutions/p1-2.patch + echo '#define THREAD_JOIN_IMPLEMENTED 1' > $@/pintos/src/constants.h $(run-tests) null $(clean)