summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/threads/priority-condvar.c
diff options
context:
space:
mode:
Diffstat (limited to 'pintos-progos/tests/threads/priority-condvar.c')
-rw-r--r--pintos-progos/tests/threads/priority-condvar.c53
1 files changed, 0 insertions, 53 deletions
diff --git a/pintos-progos/tests/threads/priority-condvar.c b/pintos-progos/tests/threads/priority-condvar.c
deleted file mode 100644
index c1efb1b..0000000
--- a/pintos-progos/tests/threads/priority-condvar.c
+++ /dev/null
@@ -1,53 +0,0 @@
1/* Tests that cond_signal() wakes up the highest-priority thread
2 waiting in cond_wait(). */
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_condvar_thread;
13static struct lock lock;
14static struct condition condition;
15
16void
17test_priority_condvar (void)
18{
19 int i;
20
21 /* This test does not work with the MLFQS. */
22 ASSERT (!thread_mlfqs);
23
24 lock_init (&lock);
25 cond_init (&condition);
26
27 thread_set_priority (PRI_MIN);
28 for (i = 0; i < 10; i++)
29 {
30 int priority = PRI_DEFAULT - (i + 7) % 10 - 1;
31 char name[16];
32 snprintf (name, sizeof name, "priority %d", priority);
33 thread_create (name, priority, priority_condvar_thread, NULL);
34 }
35
36 for (i = 0; i < 10; i++)
37 {
38 lock_acquire (&lock);
39 msg ("Signaling...");
40 cond_signal (&condition, &lock);
41 lock_release (&lock);
42 }
43}
44
45static void
46priority_condvar_thread (void *aux UNUSED)
47{
48 msg ("Thread %s starting.", thread_name ());
49 lock_acquire (&lock);
50 cond_wait (&condition, &lock);
51 msg ("Thread %s woke up.", thread_name ());
52 lock_release (&lock);
53}