1 /* Problem 1-3: Priority Scheduling tests.
3 Based on a test originally submitted for Stanford's CS 140 in
4 winter 1999 by Matt Franklin <startled@leland.stanford.edu>,
5 Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu
6 <yph@cs.stanford.edu>. Modified by arens. */
9 #include "tests/threads/tests.h"
10 #include "threads/init.h"
11 #include "threads/synch.h"
12 #include "threads/thread.h"
14 static thread_func acquire1_thread_func;
15 static thread_func acquire2_thread_func;
18 test_priority_donate_one (void)
22 /* This test does not work with the MLFQS. */
23 ASSERT (!enable_mlfqs);
25 /* Make sure our priority is the default. */
26 ASSERT (thread_get_priority () == PRI_DEFAULT);
30 thread_create ("acquire1", PRI_DEFAULT - 1, acquire1_thread_func, &lock);
31 msg ("This thread should have priority %d. Actual priority: %d.",
32 PRI_DEFAULT - 1, thread_get_priority ());
33 thread_create ("acquire2", PRI_DEFAULT - 2, acquire2_thread_func, &lock);
34 msg ("This thread should have priority %d. Actual priority: %d.",
35 PRI_DEFAULT - 2, thread_get_priority ());
37 msg ("acquire2, acquire1 must already have finished, in that order.");
38 msg ("This should be the last line before finishing this test.");
42 acquire1_thread_func (void *lock_)
44 struct lock *lock = lock_;
47 msg ("acquire1: got the lock");
49 msg ("acquire1: done");
53 acquire2_thread_func (void *lock_)
55 struct lock *lock = lock_;
58 msg ("acquire2: got the lock");
60 msg ("acquire2: done");