1 /* Problem 1-3: Priority Scheduling tests.
3 Based on a test originally submitted for Stanford's CS 140 in
4 winter 1999 by by Matt Franklin
5 <startled@leland.stanford.edu>, Greg Hutchins
6 <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
10 #error This test not applicable with MLFQS enabled.
13 #include "threads/test.h"
15 #include "threads/synch.h"
16 #include "threads/thread.h"
18 static void test_donate_multiple (void);
23 /* Make sure our priority is the default. */
24 ASSERT (thread_get_priority () == PRI_DEFAULT);
26 test_donate_multiple ();
29 static thread_func a_thread_func;
30 static thread_func b_thread_func;
33 test_donate_multiple (void)
38 "Testing multiple priority donation.\n"
39 "If the statements printed below are all true, you pass.\n");
47 thread_create ("a", PRI_DEFAULT + 1, a_thread_func, &a);
48 printf (" 1. Main thread should have priority %d. Actual priority: %d.\n",
49 PRI_DEFAULT + 1, thread_get_priority ());
51 thread_create ("b", PRI_DEFAULT + 2, b_thread_func, &b);
52 printf (" 2. Main thread should have priority %d. Actual priority: %d.\n",
53 PRI_DEFAULT + 2, thread_get_priority ());
56 printf (" 5. Thread b should have just finished.\n");
57 printf (" 6. Main thread should have priority %d. Actual priority: %d.\n",
58 PRI_DEFAULT + 1, thread_get_priority ());
61 printf (" 9. Thread a should have just finished.\n");
62 printf ("10. Main thread should have priority %d. Actual priority: %d.\n",
63 PRI_DEFAULT, thread_get_priority ());
64 printf ("Multiple priority priority donation test finished.\n");
68 a_thread_func (void *lock_)
70 struct lock *lock = lock_;
73 printf (" 7. Thread a acquired lock a.\n");
75 printf (" 8. Thread b finished.\n");
79 b_thread_func (void *lock_)
81 struct lock *lock = lock_;
84 printf (" 3. Thread b acquired lock b.\n");
86 printf (" 4. Thread b finished.\n");