Fix two bugs in the base Pintos code:
[pintos-anon] / src / tests / threads / priority-donate-one.c
index 087371f1a4cb491a5f1819437a1d22fcca5c84b6..3189f3a0b94a030290b286ea4a78623ddd5ea2e3 100644 (file)
@@ -1,10 +1,13 @@
-/* Problem 1-3: Priority Scheduling tests.
+/* The main thread acquires a lock.  Then it creates two
+   higher-priority threads that block acquiring the lock, causing
+   them to donate their priorities to the main thread.  When the
+   main thread releases the lock, the other threads should
+   acquire it in priority order.
 
    Based on a test originally submitted for Stanford's CS 140 in
-   winter 1999 by by Matt Franklin
-   <startled@leland.stanford.edu>, Greg Hutchins
-   <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
-   Modified by arens. */
+   winter 1999 by Matt Franklin <startled@leland.stanford.edu>,
+   Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu
+   <yph@cs.stanford.edu>.  Modified by arens. */
 
 #include <stdio.h>
 #include "tests/threads/tests.h"
@@ -21,19 +24,19 @@ test_priority_donate_one (void)
   struct lock lock;
 
   /* This test does not work with the MLFQS. */
-  ASSERT (!enable_mlfqs);
+  ASSERT (!thread_mlfqs);
 
   /* Make sure our priority is the default. */
   ASSERT (thread_get_priority () == PRI_DEFAULT);
 
   lock_init (&lock);
   lock_acquire (&lock);
-  thread_create ("acquire1", PRI_DEFAULT - 1, acquire1_thread_func, &lock);
+  thread_create ("acquire1", PRI_DEFAULT + 1, acquire1_thread_func, &lock);
   msg ("This thread should have priority %d.  Actual priority: %d.",
-       PRI_DEFAULT - 1, thread_get_priority ());
-  thread_create ("acquire2", PRI_DEFAULT - 2, acquire2_thread_func, &lock);
+       PRI_DEFAULT + 1, thread_get_priority ());
+  thread_create ("acquire2", PRI_DEFAULT + 2, acquire2_thread_func, &lock);
   msg ("This thread should have priority %d.  Actual priority: %d.",
-       PRI_DEFAULT - 2, thread_get_priority ());
+       PRI_DEFAULT + 2, thread_get_priority ());
   lock_release (&lock);
   msg ("acquire2, acquire1 must already have finished, in that order.");
   msg ("This should be the last line before finishing this test.");