Make tests public. Rewrite most tests. Add tests.
[pintos-anon] / src / tests / threads / priority-change.c
1 #include <stdio.h>
2 #include "tests/threads/tests.h"
3 #include "threads/init.h"
4 #include "threads/thread.h"
5
6 static thread_func changing_thread;
7
8 void
9 test_priority_change (void) 
10 {
11   /* This test does not work with the MLFQS. */
12   ASSERT (!enable_mlfqs);
13
14   msg ("Creating a high-priority thread 2.");
15   thread_create ("thread 2", PRI_DEFAULT - 1, changing_thread, NULL);
16   msg ("Thread 2 should have just lowered its priority.");
17   thread_set_priority (PRI_DEFAULT + 2);
18   msg ("Thread 2 should have just exited.");
19 }
20
21 static void
22 changing_thread (void *aux UNUSED) 
23 {
24   msg ("Thread 2 now lowering priority.");
25   thread_set_priority (PRI_DEFAULT + 1);
26   msg ("Thread 2 exiting.");
27 }