Add another test that locks & unlocks in FIFO order instead of stack
[pintos-anon] / src / tests / threads / priority-donate-multiple.c
index 836f3ed028f62785d0f36fcbe52a9f4a8b149421..e1bccbdb4b567baef5c1767173ff9271aeda74c9 100644 (file)
@@ -1,4 +1,10 @@
-/* Based on a test originally submitted for Stanford's CS 140 in
+/* The main thread acquires locks A and B, then it creates two
+   higher-priority threads.  Each of these threads blocks
+   acquiring one of the locks and thus donate their priority to
+   the main thread.  The main thread releases the locks in turn
+   and relinquishes its donated priorities.
+   
+   Based on a test originally submitted for Stanford's CS 140 in
    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. */
@@ -29,18 +35,18 @@ test_priority_donate_multiple (void)
   lock_acquire (&a);
   lock_acquire (&b);
 
-  thread_create ("a", PRI_DEFAULT - 1, a_thread_func, &a);
+  thread_create ("a", PRI_DEFAULT + 1, a_thread_func, &a);
   msg ("Main thread should have priority %d.  Actual priority: %d.",
-       PRI_DEFAULT - 1, thread_get_priority ());
+       PRI_DEFAULT + 1, thread_get_priority ());
 
-  thread_create ("b", PRI_DEFAULT - 2, b_thread_func, &b);
+  thread_create ("b", PRI_DEFAULT + 2, b_thread_func, &b);
   msg ("Main thread should have priority %d.  Actual priority: %d.",
-       PRI_DEFAULT - 2, thread_get_priority ());
+       PRI_DEFAULT + 2, thread_get_priority ());
 
   lock_release (&b);
   msg ("Thread b should have just finished.");
   msg ("Main thread should have priority %d.  Actual priority: %d.",
-       PRI_DEFAULT - 1, thread_get_priority ());
+       PRI_DEFAULT + 1, thread_get_priority ());
 
   lock_release (&a);
   msg ("Thread a should have just finished.");