Use runtime options instead of conditional compilation for MLFQS,
authorBen Pfaff <blp@cs.stanford.edu>
Wed, 13 Apr 2005 05:32:09 +0000 (05:32 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Wed, 13 Apr 2005 05:32:09 +0000 (05:32 +0000)
RANDOM_REPLACEMENT, extra credit.  Update documentation, grading.

20 files changed:
doc/standards.texi
doc/threads.texi
doc/vm.texi
grading/lib/Pintos/Grading.pm
grading/threads/alarm-multiple.c
grading/threads/alarm-single.c
grading/threads/priority-donate-multiple.c
grading/threads/priority-donate-nest.c
grading/threads/priority-donate-one.c
grading/threads/priority-fifo.c
grading/threads/priority-preempt.c
grading/threads/run-tests
src/Makefile.build
src/constants.h [deleted file]
src/tests/threads/p1-1.c
src/tests/threads/p1-2.c
src/threads/init.c
src/threads/init.h
src/threads/test.c
src/threads/test.h

index a1c70a47961a69baac2f0bfe906c15870c88677d..162ec44ecfde7f06cb4dacd851b991b39dd88c89 100644 (file)
@@ -56,53 +56,14 @@ read.  We're only going to do a compile in the directory for the current
 project, so you don't need to make sure that the previous projects also
 compile.
 
 project, so you don't need to make sure that the previous projects also
 compile.
 
-@node Conditional Compilation
-@section Conditional Compilation
-
-Given the scope and complexity of your assignments this quarter, you
-may find it convenient while coding and debugging (and we will find it
-convenient while grading) to be able to independently turn different
-parts of the assignments on and off.  To do this, choose a macro name
-and use it in conditional
-compilation directives, e.g.:
-
-@example
-#ifdef @var{NAME}
-@dots{}your code@dots{}
-#endif
-@end example
-
-In general, the code that you turn in must not depend on conditional
-compilation directives.  Project code should be written so that all of
-the subproblems for the project function together, and it should
-compile properly without the need for any new macros to be defined.
-There are a few exceptions:
-
-@itemize @bullet
-@item
-Problem 1-3, the advanced scheduler.  We must be able to turn this on
-and off with a compile-time directive.  You must use the macro name we
-specify for that part.  @xref{Problem 1-3 Advanced Scheduler}, for
-details.
-
-@item
-Problem 3-2, paging to and from disk.  Your page replacement policy must
-default to LRU-like replacement, but we must be able to choose a random
-replacement policy with a compile-time directive.  You must use the
-macro name we specify for that part.  @xref{Problem 3-2 Paging To and
-From Disk}, for details.
-
-@item
-Code written for extra credit may be included conditionally.  If the
-extra credit code changes the normally expected functionality of the
-code, then it @emph{must} be included conditionally, and it must not
-be enabled by default.
-@end itemize
-
-You can use @file{constants.h} in @file{pintos/src} to define macros
-for conditional compilation.  We will replace the @file{constants.h}
-that you supply with one of our own when we test your code, so do not
-define anything important in it.
+Project code should be written so that all of the subproblems for the
+project function together, that is, without the need to rebuild with
+different macros defined, etc.  If you do extra credit work that
+changes normal Pintos behavior so as to interfere with grading, then
+you must implement it so that it only acts that way when given a
+special command-line option of the form @option{-o @var{name}}, where
+@var{name} is a name of your choice.  You can add such an option by
+modifying @func{argv_init} in @file{threads/init.c}.
 
 @node C99
 @section C99
 
 @node C99
 @section C99
index 061c6ee29934640c5d2d810e17773c461d451135..b001548c05b5fd3533bf7f2ffd2420735f7a7935 100644 (file)
@@ -499,10 +499,12 @@ relative to the original Pintos scheduling algorithm (round robin) for
 at least one workload of your own design (i.e.@: in addition to the
 provided test).
 
 at least one workload of your own design (i.e.@: in addition to the
 provided test).
 
-You must write your code so that we can turn the MLFQS on and off at
-compile time.  By default, it must be off, but we must be able to turn
-it on by inserting the line @code{#define MLFQS 1} in
-@file{constants.h}.  @xref{Conditional Compilation}, for details.
+You must write your code so that we can choose a scheduling algorithm
+policy at Pintos startup time.  By default, the round-robin scheduler
+must be active, but we must be able to choose the MLFQS by invoking
+@command{pintos} with the @option{-o mlfqs} option.  Passing this
+option sets @code{enable_mlfqs}, declared in @file{threads/init.h}, to
+true.
 
 @node Threads FAQ
 @section FAQ
 
 @node Threads FAQ
 @section FAQ
index 99f4f4fb53fd3f05de770fc70670796e80de6e81..f922810e17baa5eb93e897542d08b636790ed6a6 100644 (file)
@@ -412,11 +412,12 @@ pages less frequently using your algorithm than using some inferior
 page replacement policy.  The canonical example of a poor page
 replacement policy is random replacement.
 
 page replacement policy.  The canonical example of a poor page
 replacement policy is random replacement.
 
-You must write your code so that we can choose a page replacement policy
-at compile time.  By default, the LRU-like algorithm must be in effect,
-but we must be able to choose random replacement by inserting the line
-@code{#define RANDOM_REPLACEMENT 1} in @file{constants.h}.
-@xref{Conditional Compilation}, for details.
+You must write your code so that we can choose a page replacement
+policy at Pintos startup time.  By default, the LRU-like algorithm
+must be in effect, but we must be able to choose random replacement by
+invoking @command{pintos} with the @option{-o random-paging} option.
+Passing this option sets @code{enable_random_paging}, declared in
+@file{threads/init.h}, to true.
 
 Since you will already be paging from disk, you should implement a
 ``lazy'' loading scheme for new processes.  When a process is created,
 
 Since you will already be paging from disk, you should implement a
 ``lazy'' loading scheme for new processes.  When a process is created,
index 240b16ebb5ff0fe73697e885d372e146e49a4a12..ad2a8259ea85a88683357e883895ea5a6ed02c04 100644 (file)
@@ -96,9 +96,8 @@ EOF
 \f
 # Source tarballs.
 
 \f
 # Source tarballs.
 
-# Extracts the group's source files into pintos/src,
-# applies any patches providing in the grading directory,
-# and installs a default pintos/src/constants.h
+# Extracts the group's source files into pintos/src
+# and applies any patches providing in the grading directory.
 sub extract_sources {
     # Make sure the output dir exists.
     -d ("output") || mkdir ("output") or die "output: mkdir: $!\n";
 sub extract_sources {
     # Make sure the output dir exists.
     -d ("output") || mkdir ("output") or die "output: mkdir: $!\n";
@@ -137,11 +136,6 @@ sub extract_sources {
        xsystem ("patch -fs -p0 < $patch",
                 LOG => $stem, DIE => "applying patch $stem failed\n");
     }
        xsystem ("patch -fs -p0 < $patch",
                 LOG => $stem, DIE => "applying patch $stem failed\n");
     }
-
-    # Install default pintos/src/constants.h (which is empty).
-    open (CONSTANTS, ">pintos/src/constants.h")
-       or die "constants.h: create: $!\n";
-    close CONSTANTS;
 }
 
 # Returns the name of the tarball to extract.
 }
 
 # Returns the name of the tarball to extract.
index 6e7c3d4079adc638ef593a35f437a7bf2ea1206c..f5085c0e60542bb314c78dbfebb1bf168ab4a55e 100644 (file)
 #include "threads/thread.h"
 #include "devices/timer.h"
 
 #include "threads/thread.h"
 #include "devices/timer.h"
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   test_sleep (5, 7);
 }
 \f
   test_sleep (5, 7);
 }
 \f
index aff206467e771242c1becf9ebe67f376946c5faf..ebed46f6d801c797423eda1e0370511a580e405f 100644 (file)
 #include "threads/thread.h"
 #include "devices/timer.h"
 
 #include "threads/thread.h"
 #include "devices/timer.h"
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   test_sleep (5, 1);
 }
 \f
   test_sleep (5, 1);
 }
 \f
index a00447e43ac940c4559f8f0974fe9a2cb9293635..db527dea1219507ac12dc9b82cd5aab5787917d6 100644 (file)
@@ -6,10 +6,6 @@
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
@@ -20,6 +16,9 @@ static void test_donate_multiple (void);
 void
 test (void) 
 {
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
index 73c78664e70da3cfb129588a9cfa763eac86fe2f..8e7316ffe5fbe3ac822492f3e2fe143fca6bb344 100644 (file)
@@ -6,10 +6,6 @@
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
@@ -20,6 +16,9 @@ static void test_donate_nest (void);
 void
 test (void) 
 {
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
index 35f135c3d9ef6c372cd0af29f92aa2750a37705e..afc1e830ffb07d2d14d734e0081552509a927aae 100644 (file)
@@ -6,10 +6,6 @@
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
@@ -20,6 +16,9 @@ static void test_donate_return (void);
 void
 test (void) 
 {
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
index 6f8fa9b73a21eaff7c16e6a43690f67ab184a0d2..01cc7a7737071f2878c818aad360bf6948d700e5 100644 (file)
@@ -6,10 +6,6 @@
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 #include "threads/test.h"
 #include <stdio.h>
 #include "devices/timer.h"
 #include "threads/test.h"
 #include <stdio.h>
 #include "devices/timer.h"
@@ -22,6 +18,9 @@ static void test_fifo (void);
 void
 test (void) 
 {
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
index 1e2a2685872735d7bc02414ac5ed8e0114e2dbc6..8953748afb6ec8fefd35bba2bc481ede0eb60c78 100644 (file)
@@ -6,10 +6,6 @@
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
@@ -20,6 +16,9 @@ static void test_preempt (void);
 void
 test (void) 
 {
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
index 534621187ac141ee454913cf0577c612c5a518e6..bd705e43b2da871acc5e51a3a5d034e8e9bcd646 100755 (executable)
@@ -51,14 +51,6 @@ die "Don't know how to '$action'";
 # Runs $test in directory output/$test.
 # Returns 'ok' if it went ok, otherwise an explanation.
 sub run_test {
 # Runs $test in directory output/$test.
 # Returns 'ok' if it went ok, otherwise an explanation.
 sub run_test {
-    # Change constants.h if necessary.
-    my ($defines) = $test ne 'mlfqs-on' ? "" : "#define MLFQS 1\n";
-    if ($defines ne snarf ("pintos/src/constants.h")) {
-       open (CONSTANTS, ">pintos/src/constants.h");
-       print CONSTANTS $defines;
-       close (CONSTANTS);
-    }
-
     # Changes devices/timer.c if necessary.
     my ($new_time_slice) = $test eq 'priority-fifo' ? 100 : 1;
     my (@timer_c) = snarf ("pintos/src/devices/timer.c");
     # Changes devices/timer.c if necessary.
     my ($new_time_slice) = $test eq 'priority-fifo' ? 100 : 1;
     my (@timer_c) = snarf ("pintos/src/devices/timer.c");
@@ -103,7 +95,9 @@ sub run_test {
 
     # Run.
     my ($timeout) = $test !~ /^mlfqs/ ? 15 : 600;
 
     # Run.
     my ($timeout) = $test !~ /^mlfqs/ ? 15 : 600;
-    return run_pintos (["-v", "run", "-q"],
+    my (@command) = ("-v", "run", "-q");
+    push (@command, "-o mlfqs") if $test eq 'mlfqs-on';
+    return run_pintos (\@command,
                       CHDIR => "pintos/src/threads/build",
                       LOG => "$test/run",
                       TIMEOUT => $timeout);
                       CHDIR => "pintos/src/threads/build",
                       LOG => "$test/run",
                       TIMEOUT => $timeout);
index df3877705db29ff9deb09bf13f2e8c1d11d18abe..e124011ac646210885fc7c311080ede3e6bfd3d3 100644 (file)
@@ -7,8 +7,7 @@ VPATH = ../..
 
 # Compiler and assembler options.
 DEFINES += -DKERNEL
 
 # Compiler and assembler options.
 DEFINES += -DKERNEL
-CPPFLAGS = -nostdinc -I../.. -I- -I../../lib -I../../lib/kernel        \
-          -include constants.h
+CPPFLAGS = -nostdinc -I../.. -I- -I../../lib -I../../lib/kernel
 
 # Core kernel.
 threads_SRC  = threads/init.c          # Main program.
 
 # Core kernel.
 threads_SRC  = threads/init.c          # Main program.
diff --git a/src/constants.h b/src/constants.h
deleted file mode 100644 (file)
index 8ffe2f6..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-/* Use this header file to define macros for configuring
-   compilation.  This file will be replaced by the TAs when your
-   code is tested, using the macros described in the course
-   documentation.  Your code should not require other macros to
-   be defined here to function properly. */
-
-/* Example definition. */
-/*#define MACRONAME 1 */
index 627bba5fc2e5109dff8a44b6e1fa99d92e5126fb..694ea0b98c1b8706d3afe8cff9864221bf9b2231 100644 (file)
 #include "threads/thread.h"
 #include "devices/timer.h"
 
 #include "threads/thread.h"
 #include "devices/timer.h"
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Easy test: 5 threads sleep once each. */
   test_sleep (5, 1);
 
   /* Easy test: 5 threads sleep once each. */
   test_sleep (5, 1);
 
index 50a4fcfa803de0416a86f1e0433096b745df278f..e96f03c93bf14b7476e902092c78d020b5841222 100644 (file)
@@ -6,10 +6,6 @@
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
    <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
    Modified by arens. */
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
 #include "threads/test.h"
 #include <stdio.h>
 #include "threads/synch.h"
@@ -22,6 +18,9 @@ static void test_donate_return (void);
 void
 test (void) 
 {
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
index 8b2b7f76a4f89ba3d66be22e0a925e9682b4139a..51d6bdd43d7ee39ed3eb1b7dcf3b20881639ba48 100644 (file)
@@ -39,16 +39,28 @@ size_t ram_pages;
 /* Page directory with kernel mappings only. */
 uint32_t *base_page_dir;
 
 /* Page directory with kernel mappings only. */
 uint32_t *base_page_dir;
 
-#ifdef FILESYS
-/* -f: Format the filesystem? */
-static bool format_filesys;
-#endif
+/* -o mlfqs:
+   If false (default), use round-robin scheduler.
+   If true, use multi-level feedback queue scheduler. */
+bool enable_mlfqs;
 
 #ifdef USERPROG
 /* -ex: Initial program to run. */
 static char *initial_program;
 #endif
 
 
 #ifdef USERPROG
 /* -ex: Initial program to run. */
 static char *initial_program;
 #endif
 
+#ifdef VM
+/* -o random-paging:
+   If false (default), use LRU page replacement policy.
+   If true, use random page replacement policy. */
+bool enable_random_paging;
+#endif
+
+#ifdef FILESYS
+/* -f: Format the filesystem? */
+static bool format_filesys;
+#endif
+
 /* -q: Power off after kernel tasks complete? */
 bool power_off_when_done;
 
 /* -q: Power off after kernel tasks complete? */
 bool power_off_when_done;
 
@@ -220,7 +232,19 @@ argv_init (void)
 
   /* Parse the words. */
   for (i = 0; i < argc; i++)
 
   /* Parse the words. */
   for (i = 0; i < argc; i++)
-    if (!strcmp (argv[i], "-rs")) 
+    if (!strcmp (argv[i], "-o"))
+      {
+        i++;
+        if (!strcmp (argv[i], "mlfqs"))
+          enable_mlfqs = true;
+#ifdef VM
+        else if (!strcmp (argv[i], "random-paging"))
+          enable_random_paging = true;
+#endif
+        else
+          PANIC ("unknown option `-o %s' (use -u for help)", argv[i]);
+      }
+    else if (!strcmp (argv[i], "-rs")) 
       random_init (atoi (argv[++i]));
     else if (!strcmp (argv[i], "-q"))
       power_off_when_done = true;
       random_init (atoi (argv[++i]));
     else if (!strcmp (argv[i], "-q"))
       power_off_when_done = true;
@@ -251,11 +275,14 @@ argv_init (void)
       {
         printf (
           "Kernel options:\n"
       {
         printf (
           "Kernel options:\n"
-          " -rs SEED            Set random seed to SEED.\n"
+          " -o mlfqs            Use multi-level feedback queue scheduler.\n"
 #ifdef USERPROG
           " -ex 'PROG [ARG...]' Run PROG, passing the optional arguments.\n"
           " -ul USER_MAX        Limit user memory to USER_MAX pages.\n"
 #endif
 #ifdef USERPROG
           " -ex 'PROG [ARG...]' Run PROG, passing the optional arguments.\n"
           " -ul USER_MAX        Limit user memory to USER_MAX pages.\n"
 #endif
+#ifdef VM
+          " -o random-paging    Use random page replacement policy.\n"
+#endif
 #ifdef FILESYS
           " -f                  Format the filesystem disk (hdb or hd0:1).\n"
           " -ci FILE SIZE       Copy SIZE bytes from the scratch disk (hdc\n"
 #ifdef FILESYS
           " -f                  Format the filesystem disk (hdb or hd0:1).\n"
           " -ci FILE SIZE       Copy SIZE bytes from the scratch disk (hdc\n"
@@ -266,6 +293,7 @@ argv_init (void)
           " -r FILE             Delete FILE.\n"
           " -ls                 List files in the root directory.\n"
 #endif
           " -r FILE             Delete FILE.\n"
           " -ls                 List files in the root directory.\n"
 #endif
+          " -rs SEED            Set random seed to SEED.\n"
           " -q                  Power off after doing requested actions.\n"
           " -u                  Print this help message and power off.\n"
           );
           " -q                  Power off after doing requested actions.\n"
           " -u                  Print this help message and power off.\n"
           );
index a6fec055d0b66067fd590441b06c2d2a141492ea..45e9545f0a190261d1687c99ab6f142285bc00d1 100644 (file)
@@ -12,6 +12,18 @@ extern size_t ram_pages;
 /* Page directory with kernel mappings only. */
 extern uint32_t *base_page_dir;
 
 /* Page directory with kernel mappings only. */
 extern uint32_t *base_page_dir;
 
+/* -o mlfqs:
+   If false (default), use round-robin scheduler.
+   If true, use multi-level feedback queue scheduler. */
+extern bool enable_mlfqs;
+
+#ifdef VM
+/* -o random-paging:
+   If false (default), use LRU page replacement policy.
+   If true, use random page replacement policy. */
+extern bool enable_random_paging;
+#endif
+
 /* -q: Power off when kernel tasks complete? */
 extern bool power_off_when_done;
 
 /* -q: Power off when kernel tasks complete? */
 extern bool power_off_when_done;
 
index 627bba5fc2e5109dff8a44b6e1fa99d92e5126fb..694ea0b98c1b8706d3afe8cff9864221bf9b2231 100644 (file)
 #include "threads/thread.h"
 #include "devices/timer.h"
 
 #include "threads/thread.h"
 #include "devices/timer.h"
 
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
 static void test_sleep (int thread_cnt, int iterations);
 
 void
 test (void) 
 {
+  /* This test does not work with the MLFQS. */
+  ASSERT (!enable_mlfqs);
+
   /* Easy test: 5 threads sleep once each. */
   test_sleep (5, 1);
 
   /* Easy test: 5 threads sleep once each. */
   test_sleep (5, 1);
 
index dde08fab356d41ceb893578bfe5d6f43887fb66f..d6b3ca836abe63ebecf63ed716a44b1ad954b43b 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef THREADS_TEST_H
 #define THREADS_TEST_H
 
 #ifndef THREADS_TEST_H
 #define THREADS_TEST_H
 
+#include "threads/init.h"
+
 void test (void);
 
 #endif /* threads/test.h */
 void test (void);
 
 #endif /* threads/test.h */