2 #include "tests/threads/tests.h"
3 #include "threads/init.h"
4 #include "threads/synch.h"
5 #include "threads/thread.h"
7 static thread_func acquire1_thread_func;
8 static thread_func acquire2_thread_func;
11 test_priority_donate_one (void)
15 /* This test does not work with the MLFQS. */
16 ASSERT (!enable_mlfqs);
18 /* Make sure our priority is the default. */
19 ASSERT (thread_get_priority () == PRI_DEFAULT);
23 thread_create ("acquire1", PRI_DEFAULT - 1, acquire1_thread_func, &lock);
24 msg ("This thread should have priority %d. Actual priority: %d.",
25 PRI_DEFAULT - 1, thread_get_priority ());
26 thread_create ("acquire2", PRI_DEFAULT - 2, acquire2_thread_func, &lock);
27 msg ("This thread should have priority %d. Actual priority: %d.",
28 PRI_DEFAULT - 2, thread_get_priority ());
30 msg ("acquire2, acquire1 must already have finished, in that order.");
31 msg ("This should be the last line before finishing this test.");
35 acquire1_thread_func (void *lock_)
37 struct lock *lock = lock_;
40 msg ("acquire1: got the lock");
42 msg ("acquire1: done");
46 acquire2_thread_func (void *lock_)
48 struct lock *lock = lock_;
51 msg ("acquire2: got the lock");
53 msg ("acquire2: done");