1 /* Based on a test originally submitted for Stanford's CS 140 in
2 winter 1999 by Matt Franklin <startled@leland.stanford.edu>,
3 Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu
4 <yph@cs.stanford.edu>. Modified by arens. */
7 #include "tests/threads/tests.h"
8 #include "threads/init.h"
9 #include "threads/synch.h"
10 #include "threads/thread.h"
12 static thread_func a_thread_func;
13 static thread_func b_thread_func;
16 test_priority_donate_multiple (void)
20 /* This test does not work with the MLFQS. */
21 ASSERT (!enable_mlfqs);
23 /* Make sure our priority is the default. */
24 ASSERT (thread_get_priority () == PRI_DEFAULT);
32 thread_create ("a", PRI_DEFAULT - 1, a_thread_func, &a);
33 msg ("Main thread should have priority %d. Actual priority: %d.",
34 PRI_DEFAULT - 1, thread_get_priority ());
36 thread_create ("b", PRI_DEFAULT - 2, b_thread_func, &b);
37 msg ("Main thread should have priority %d. Actual priority: %d.",
38 PRI_DEFAULT - 2, thread_get_priority ());
41 msg ("Thread b should have just finished.");
42 msg ("Main thread should have priority %d. Actual priority: %d.",
43 PRI_DEFAULT - 1, thread_get_priority ());
46 msg ("Thread a should have just finished.");
47 msg ("Main thread should have priority %d. Actual priority: %d.",
48 PRI_DEFAULT, thread_get_priority ());
52 a_thread_func (void *lock_)
54 struct lock *lock = lock_;
57 msg ("Thread a acquired lock a.");
59 msg ("Thread a finished.");
63 b_thread_func (void *lock_)
65 struct lock *lock = lock_;
68 msg ("Thread b acquired lock b.");
70 msg ("Thread b finished.");