summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/threads/priority-sema.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 /pintos-progos/tests/threads/priority-sema.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 'pintos-progos/tests/threads/priority-sema.c')
-rw-r--r--pintos-progos/tests/threads/priority-sema.c45
1 files changed, 0 insertions, 45 deletions
diff --git a/pintos-progos/tests/threads/priority-sema.c b/pintos-progos/tests/threads/priority-sema.c
deleted file mode 100644
index 2834a88..0000000
--- a/pintos-progos/tests/threads/priority-sema.c
+++ /dev/null
@@ -1,45 +0,0 @@
1/* Tests that the highest-priority thread waiting on a semaphore
2 is the first to wake up. */
3
4#include <stdio.h>
5#include "tests/threads/tests.h"
6#include "threads/init.h"
7#include "threads/malloc.h"
8#include "threads/synch.h"
9#include "threads/thread.h"
10#include "devices/timer.h"
11
12static thread_func priority_sema_thread;
13static struct semaphore sema;
14
15void
16test_priority_sema (void)
17{
18 int i;
19
20 /* This test does not work with the MLFQS. */
21 ASSERT (!thread_mlfqs);
22
23 sema_init (&sema, 0);
24 thread_set_priority (PRI_MIN);
25 for (i = 0; i < 10; i++)
26 {
27 int priority = PRI_DEFAULT - (i + 3) % 10 - 1;
28 char name[16];
29 snprintf (name, sizeof name, "priority %d", priority);
30 thread_create (name, priority, priority_sema_thread, NULL);
31 }
32
33 for (i = 0; i < 10; i++)
34 {
35 sema_up (&sema);
36 msg ("Back in main thread.");
37 }
38}
39
40static void
41priority_sema_thread (void *aux UNUSED)
42{
43 sema_down (&sema);
44 msg ("Thread %s woke up.", thread_name ());
45}