summaryrefslogtreecommitdiffstats
path: root/pintos-progos/tests/threads/priority-donate-one.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-donate-one.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-donate-one.c')
-rw-r--r--pintos-progos/tests/threads/priority-donate-one.c65
1 files changed, 0 insertions, 65 deletions
diff --git a/pintos-progos/tests/threads/priority-donate-one.c b/pintos-progos/tests/threads/priority-donate-one.c
deleted file mode 100644
index 3189f3a..0000000
--- a/pintos-progos/tests/threads/priority-donate-one.c
+++ /dev/null
@@ -1,65 +0,0 @@
1/* The main thread acquires a lock. Then it creates two
2 higher-priority threads that block acquiring the lock, causing
3 them to donate their priorities to the main thread. When the
4 main thread releases the lock, the other threads should
5 acquire it in priority order.
6
7 Based on a test originally submitted for Stanford's CS 140 in
8 winter 1999 by Matt Franklin <startled@leland.stanford.edu>,
9 Greg Hutchins <gmh@leland.stanford.edu>, Yu Ping Hu
10 <yph@cs.stanford.edu>. Modified by arens. */
11
12#include <stdio.h>
13#include "tests/threads/tests.h"
14#include "threads/init.h"
15#include "threads/synch.h"
16#include "threads/thread.h"
17
18static thread_func acquire1_thread_func;
19static thread_func acquire2_thread_func;
20
21void
22test_priority_donate_one (void)
23{
24 struct lock lock;
25
26 /* This test does not work with the MLFQS. */
27 ASSERT (!thread_mlfqs);
28
29 /* Make sure our priority is the default. */
30 ASSERT (thread_get_priority () == PRI_DEFAULT);
31
32 lock_init (&lock);
33 lock_acquire (&lock);
34 thread_create ("acquire1", PRI_DEFAULT + 1, acquire1_thread_func, &lock);
35 msg ("This thread should have priority %d. Actual priority: %d.",
36 PRI_DEFAULT + 1, thread_get_priority ());
37 thread_create ("acquire2", PRI_DEFAULT + 2, acquire2_thread_func, &lock);
38 msg ("This thread should have priority %d. Actual priority: %d.",
39 PRI_DEFAULT + 2, thread_get_priority ());
40 lock_release (&lock);
41 msg ("acquire2, acquire1 must already have finished, in that order.");
42 msg ("This should be the last line before finishing this test.");
43}
44
45static void
46acquire1_thread_func (void *lock_)
47{
48 struct lock *lock = lock_;
49
50 lock_acquire (lock);
51 msg ("acquire1: got the lock");
52 lock_release (lock);
53 msg ("acquire1: done");
54}
55
56static void
57acquire2_thread_func (void *lock_)
58{
59 struct lock *lock = lock_;
60
61 lock_acquire (lock);
62 msg ("acquire2: got the lock");
63 lock_release (lock);
64 msg ("acquire2: done");
65}