diff options
Diffstat (limited to 'pintos-progos/tests/threads/priority-sema.c')
| -rw-r--r-- | pintos-progos/tests/threads/priority-sema.c | 45 |
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 | |||
| 12 | static thread_func priority_sema_thread; | ||
| 13 | static struct semaphore sema; | ||
| 14 | |||
| 15 | void | ||
| 16 | test_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 | |||
| 40 | static void | ||
| 41 | priority_sema_thread (void *aux UNUSED) | ||
| 42 | { | ||
| 43 | sema_down (&sema); | ||
| 44 | msg ("Thread %s woke up.", thread_name ()); | ||
| 45 | } | ||
