projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use runtime options instead of conditional compilation for MLFQS,
[pintos-anon]
/
grading
/
threads
/
priority-donate-one.c
diff --git
a/grading/threads/priority-donate-one.c
b/grading/threads/priority-donate-one.c
index e6382bdf9c911fd3786b0d0a49cbea6c5aa1fa9a..afc1e830ffb07d2d14d734e0081552509a927aae 100644
(file)
--- a/
grading/threads/priority-donate-one.c
+++ b/
grading/threads/priority-donate-one.c
@@
-6,10
+6,6
@@
<gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
Modified by arens. */
<gmh@leland.stanford.edu>, Yu Ping Hu <yph@cs.stanford.edu>.
Modified by arens. */
-#ifdef MLFQS
-#error This test not applicable with MLFQS enabled.
-#endif
-
#include "threads/test.h"
#include <stdio.h>
#include "threads/synch.h"
#include "threads/test.h"
#include <stdio.h>
#include "threads/synch.h"
@@
-20,13
+16,17
@@
static void test_donate_return (void);
void
test (void)
{
void
test (void)
{
+ /* This test does not work with the MLFQS. */
+ ASSERT (!enable_mlfqs);
+
/* Make sure our priority is the default. */
ASSERT (thread_get_priority () == PRI_DEFAULT);
test_donate_return ();
}
\f
/* Make sure our priority is the default. */
ASSERT (thread_get_priority () == PRI_DEFAULT);
test_donate_return ();
}
\f
-static thread_func acquire_thread_func;
+static thread_func acquire1_thread_func;
+static thread_func acquire2_thread_func;
static void
test_donate_return (void)
static void
test_donate_return (void)
@@
-39,25
+39,36
@@
test_donate_return (void)
lock_init (&lock, "donor");
lock_acquire (&lock);
lock_init (&lock, "donor");
lock_acquire (&lock);
- thread_create ("acquire1", PRI_DEFAULT + 1, acquire_thread_func, &lock);
+ thread_create ("acquire1", PRI_DEFAULT + 1, acquire
1
_thread_func, &lock);
printf ("This thread should have priority %d. Actual priority: %d.\n",
PRI_DEFAULT + 1, thread_get_priority ());
printf ("This thread should have priority %d. Actual priority: %d.\n",
PRI_DEFAULT + 1, thread_get_priority ());
- thread_create ("acquire2", PRI_DEFAULT + 2, acquire_thread_func, &lock);
+ thread_create ("acquire2", PRI_DEFAULT + 2, acquire
2
_thread_func, &lock);
printf ("This thread should have priority %d. Actual priority: %d.\n",
PRI_DEFAULT + 2, thread_get_priority ());
lock_release (&lock);
printf ("This thread should have priority %d. Actual priority: %d.\n",
PRI_DEFAULT + 2, thread_get_priority ());
lock_release (&lock);
- printf ("acquire2
and
acquire1 must already have finished, in that order.\n"
+ printf ("acquire2
,
acquire1 must already have finished, in that order.\n"
"This should be the last line before finishing this test.\n"
"Priority donation test done.\n");
}
static void
"This should be the last line before finishing this test.\n"
"Priority donation test done.\n");
}
static void
-acquire_thread_func (void *lock_)
+acquire1_thread_func (void *lock_)
+{
+ struct lock *lock = lock_;
+
+ lock_acquire (lock);
+ printf ("acquire1: got the lock\n");
+ lock_release (lock);
+ printf ("acquire1: done\n");
+}
+
+static void
+acquire2_thread_func (void *lock_)
{
struct lock *lock = lock_;
lock_acquire (lock);
{
struct lock *lock = lock_;
lock_acquire (lock);
- printf ("
%s: got the lock\n", thread_name ()
);
+ printf ("
acquire2: got the lock\n"
);
lock_release (lock);
lock_release (lock);
- printf ("
%s: done\n", thread_name ()
);
+ printf ("
acquire2: done\n"
);
}
}