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 acquire1_thread_func;
13 static thread_func acquire2_thread_func;
16 test_priority_donate_one (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);
28 thread_create ("acquire1", PRI_DEFAULT - 1, acquire1_thread_func, &lock);
29 msg ("This thread should have priority %d. Actual priority: %d.",
30 PRI_DEFAULT - 1, thread_get_priority ());
31 thread_create ("acquire2", PRI_DEFAULT - 2, acquire2_thread_func, &lock);
32 msg ("This thread should have priority %d. Actual priority: %d.",
33 PRI_DEFAULT - 2, thread_get_priority ());
35 msg ("acquire2, acquire1 must already have finished, in that order.");
36 msg ("This should be the last line before finishing this test.");
40 acquire1_thread_func (void *lock_)
42 struct lock *lock = lock_;
45 msg ("acquire1: got the lock");
47 msg ("acquire1: done");
51 acquire2_thread_func (void *lock_)
53 struct lock *lock = lock_;
56 msg ("acquire2: got the lock");
58 msg ("acquire2: done");