2 #include "tests/threads/tests.h"
3 #include "threads/init.h"
4 #include "threads/malloc.h"
5 #include "threads/synch.h"
6 #include "threads/thread.h"
7 #include "devices/timer.h"
9 static thread_func priority_condvar_thread;
10 static struct lock lock;
11 static struct condition condition;
14 test_priority_condvar (void)
18 /* This test does not work with the MLFQS. */
19 ASSERT (!enable_mlfqs);
22 cond_init (&condition);
24 thread_set_priority (PRI_MAX);
25 for (i = 0; i < 10; i++)
27 int priority = (i + 7) % 10 + PRI_DEFAULT + 1;
29 snprintf (name, sizeof name, "priority %d", priority);
30 thread_create (name, priority, priority_condvar_thread, NULL);
33 for (i = 0; i < 10; i++)
37 cond_signal (&condition, &lock);
43 priority_condvar_thread (void *aux UNUSED)
45 msg ("Thread %s starting.", thread_name ());
47 cond_wait (&condition, &lock);
48 msg ("Thread %s woke up.", thread_name ());