summaryrefslogtreecommitdiffstats
path: root/tests/threads/priority-change.c
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
committermanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
commit4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch)
tree868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/threads/priority-change.c
parenteae0bd57f0a26314a94785061888d193d186944a (diff)
downloadprogos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/threads/priority-change.c')
-rw-r--r--tests/threads/priority-change.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/threads/priority-change.c b/tests/threads/priority-change.c
new file mode 100644
index 0000000..810b05a
--- /dev/null
+++ b/tests/threads/priority-change.c
@@ -0,0 +1,31 @@
1/* Verifies that lowering a thread's priority so that it is no
2 longer the highest-priority thread in the system causes it to
3 yield immediately. */
4
5#include <stdio.h>
6#include "tests/threads/tests.h"
7#include "threads/init.h"
8#include "threads/thread.h"
9
10static thread_func changing_thread;
11
12void
13test_priority_change (void)
14{
15 /* This test does not work with the MLFQS. */
16 ASSERT (!thread_mlfqs);
17
18 msg ("Creating a high-priority thread 2.");
19 thread_create ("thread 2", PRI_DEFAULT + 1, changing_thread, NULL);
20 msg ("Thread 2 should have just lowered its priority.");
21 thread_set_priority (PRI_DEFAULT - 2);
22 msg ("Thread 2 should have just exited.");
23}
24
25static void
26changing_thread (void *aux UNUSED)
27{
28 msg ("Thread 2 now lowering priority.");
29 thread_set_priority (PRI_DEFAULT - 1);
30 msg ("Thread 2 exiting.");
31}