Apply appropriate changes from main branch to bring win0405-branch up
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 11 Feb 2005 05:13:08 +0000 (05:13 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 11 Feb 2005 05:13:08 +0000 (05:13 +0000)
to date.

doc/threads.texi
doc/tour.texi
doc/vm.texi
grading/lib/Pintos/Grading.pm
grading/threads/run-tests
src/threads/interrupt.h
src/threads/intr-stubs.pl [new file with mode: 0755]
src/threads/thread.c
tests/Makefile

index 1905707ffa09a631d2a7114febf6472438b52d93..a79e474b68bf2efef7d05631dce161a45a24b9c9 100644 (file)
@@ -157,9 +157,9 @@ the kernel.
 Basic interrupt handling and functions for turning interrupts on and
 off.
 
 Basic interrupt handling and functions for turning interrupts on and
 off.
 
-@item intr-stubs.S
+@item intr-stubs.pl
 @itemx intr-stubs.h
 @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
 
 @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.
 
 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
 
 @node Problem 1-3 Priority Scheduling
 @section Problem 1-3: Priority Scheduling
 
index d1147dde6b0e91d891d5192cbf6bcc841781b920..39483a32011d6f64c0a43ac13277105d10436f0b 100644 (file)
@@ -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
 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
 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
index 6eff4925c262759137396831a46dbde7bb462d4b..4325b1361706de25909cab652022a2eb13a4c3ad 100644 (file)
@@ -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}).
 
 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::                 
 @menu
 * VM Design::                   
 * Page Faults::                 
index 6a21d5231edf2851ea6370148c9b84e0331722b9..463d475eada79a590a1241847c24778a754c1698 100644 (file)
@@ -138,9 +138,10 @@ sub extract_sources {
                 LOG => $stem, DIE => "applying patch $stem failed\n");
     }
 
                 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";
     open (CONSTANTS, ">pintos/src/constants.h")
        or die "constants.h: create: $!\n";
+    print CONSTANTS "#define THREAD_JOIN_IMPLEMENTED 1\n";
     close CONSTANTS;
 }
 
     close CONSTANTS;
 }
 
index 0852f6f99536d11953debf5d61b4141c6e8ead38..dd2e7d3de52c843656aaf1d5549ebfbd5639cdfd 100755 (executable)
@@ -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";
 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;
     if ($defines ne snarf ("pintos/src/constants.h")) {
        open (CONSTANTS, ">pintos/src/constants.h");
        print CONSTANTS $defines;
index b805671e626d6891f1b43aa06de64674f15a91d6..99abf8e3a92ddecff94064dd7bbaf5f0086e774d 100644 (file)
@@ -19,7 +19,7 @@ enum intr_level intr_disable (void);
 /* Interrupt stack frame. */
 struct intr_frame
   {
 /* 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. */
        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. */
 
     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,
     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. */
 
     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. */
     /* 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 (executable)
index 0000000..75cde7b
--- /dev/null
@@ -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
index ae92e1d646dc50d50ce02d26747ca12a8bd82236..1e5a7d27179e928cb462a813200ed1a8518ccbf4 100644 (file)
@@ -273,31 +273,6 @@ thread_yield (void)
   schedule ();
   intr_set_level (old_level);
 }
   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;
-}
 \f
 /* Idle thread.  Executes when no other thread is ready to run. */
 static void
 \f
 /* Idle thread.  Executes when no other thread is ready to run. */
 static void
index efea7a5078db3e7da0cb6621a588f4f0ed9b313f..4bdd5977703616563a802edd382f0f7f9667764d 100644 (file)
@@ -7,6 +7,9 @@ all:
 
 check:
        $(MAKE) -C .. distclean
 
 check:
        $(MAKE) -C .. distclean
+       $(MAKE) check-noclean
+
+check-noclean:
        for d in $(TESTS); do $(MAKE) $$d || exit 1; done
        @echo All tests passed.
 
        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
        $(prep-grading)
        $(mk-sandbox)
        $(apply-patch) ../solutions/p1-2.patch
+       echo '#define THREAD_JOIN_IMPLEMENTED 1' > $@/pintos/src/constants.h
        $(run-tests) null
        $(clean)
 
        $(run-tests) null
        $(clean)