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 a_thread_func;
15 static thread_func b_thread_func;
18 test_priority_donate_multiple (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);
34 thread_create ("a", PRI_DEFAULT - 1, a_thread_func, &a);
35 msg ("Main thread should have priority %d. Actual priority: %d.",
36 PRI_DEFAULT - 1, thread_get_priority ());
38 thread_create ("b", PRI_DEFAULT - 2, b_thread_func, &b);
39 msg ("Main thread should have priority %d. Actual priority: %d.",
40 PRI_DEFAULT - 2, thread_get_priority ());
43 msg ("Thread b should have just finished.");
44 msg ("Main thread should have priority %d. Actual priority: %d.",
45 PRI_DEFAULT - 1, thread_get_priority ());
48 msg ("Thread a should have just finished.");
49 msg ("Main thread should have priority %d. Actual priority: %d.",
50 PRI_DEFAULT, thread_get_priority ());
54 a_thread_func (void *lock_)
56 struct lock *lock = lock_;
59 msg ("Thread a acquired lock a.");
61 msg ("Thread a finished.");
65 b_thread_func (void *lock_)
67 struct lock *lock = lock_;
70 msg ("Thread b acquired lock b.");
72 msg ("Thread b finished.");