1 /* Problem 1-3: Priority Scheduling tests.
3 Based on a test originally submitted for Stanford's CS 140 in
4 winter 1999 by by Matt Franklin
5 <startled@leland.stanford.edu>, Greg Hutchins
6 <gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
10 #include "tests/threads/tests.h"
11 #include "threads/init.h"
12 #include "threads/synch.h"
13 #include "threads/thread.h"
15 static thread_func a_thread_func;
16 static thread_func b_thread_func;
19 test_priority_donate_multiple (void)
23 /* This test does not work with the MLFQS. */
24 ASSERT (!enable_mlfqs);
26 /* Make sure our priority is the default. */
27 ASSERT (thread_get_priority () == PRI_DEFAULT);
35 thread_create ("a", PRI_DEFAULT - 1, a_thread_func, &a);
36 msg ("Main thread should have priority %d. Actual priority: %d.",
37 PRI_DEFAULT - 1, thread_get_priority ());
39 thread_create ("b", PRI_DEFAULT - 2, b_thread_func, &b);
40 msg ("Main thread should have priority %d. Actual priority: %d.",
41 PRI_DEFAULT - 2, thread_get_priority ());
44 msg ("Thread b should have just finished.");
45 msg ("Main thread should have priority %d. Actual priority: %d.",
46 PRI_DEFAULT - 1, thread_get_priority ());
49 msg ("Thread a should have just finished.");
50 msg ("Main thread should have priority %d. Actual priority: %d.",
51 PRI_DEFAULT, thread_get_priority ());
55 a_thread_func (void *lock_)
57 struct lock *lock = lock_;
60 msg ("Thread a acquired lock a.");
62 msg ("Thread a finished.");
66 b_thread_func (void *lock_)
68 struct lock *lock = lock_;
71 msg ("Thread b acquired lock b.");
73 msg ("Thread b finished.");