projects
/
pintos-anon
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Get rid of THREAD_JOIN_IMPLEMENTED by adding thread_join() stub.
[pintos-anon]
/
src
/
tests
/
threads
/
p1-4.c
diff --git
a/src/tests/threads/p1-4.c
b/src/tests/threads/p1-4.c
index 1ec2b82e52824a1c075a77ce7eb17d1e0558388f..1f97b2e7edb6fb9ed008a2811d111f638499c9e6 100644
(file)
--- a/
src/tests/threads/p1-4.c
+++ b/
src/tests/threads/p1-4.c
@@
-4,7
+4,8
@@
Run this test with and without the MLFQS enabled. The
threads' reported test should be better with MLFQS on than
Run this test with and without the MLFQS enabled. The
threads' reported test should be better with MLFQS on than
- with it off.
+ with it off. You may have to tune the loop counts to get
+ reasonable numbers.
Based on a test originally submitted for Stanford's CS 140 in
winter 1999 by by Matt Franklin
Based on a test originally submitted for Stanford's CS 140 in
winter 1999 by by Matt Franklin
@@
-17,8
+18,10
@@
#include "threads/test.h"
#include <stdio.h>
#include "threads/test.h"
#include <stdio.h>
+#include <inttypes.h>
#include "threads/synch.h"
#include "threads/thread.h"
#include "threads/synch.h"
#include "threads/thread.h"
+#include "devices/timer.h"
static thread_func io_thread;
static thread_func cpu_thread;
static thread_func io_thread;
static thread_func cpu_thread;
@@
-27,10
+30,10
@@
static thread_func io_cpu_thread;
void
test (void)
{
void
test (void)
{
- static
const
thread_func *funcs[] = {io_thread, cpu_thread, io_cpu_thread};
+ static thread_func *funcs[] = {io_thread, cpu_thread, io_cpu_thread};
static const char *names[] = {"IO", "CPU", "IO & CPU"};
struct semaphore done[3];
static const char *names[] = {"IO", "CPU", "IO & CPU"};
struct semaphore done[3];
-
tid_t tids[3]
;
+
int i
;
printf ("\n"
"Testing multilevel feedback queue scheduler.\n");
printf ("\n"
"Testing multilevel feedback queue scheduler.\n");
@@
-38,19
+41,13
@@
test (void)
/* Start threads. */
for (i = 0; i < 3; i++)
{
/* Start threads. */
for (i = 0; i < 3; i++)
{
- sema_init (&done[i], 0);
- t
ids[i] = t
hread_create (names[i], PRI_DEFAULT, funcs[i], &done[i]);
+ sema_init (&done[i], 0
, names[i]
);
+ thread_create (names[i], PRI_DEFAULT, funcs[i], &done[i]);
}
/* Wait for threads to finish. */
for (i = 0; i < 3; i++)
}
/* Wait for threads to finish. */
for (i = 0; i < 3; i++)
- {
-#ifdef THREAD_JOIN_IMPLEMENTED
- thread_join (tids[i]);
-#else
- sema_down (&done[i]);
-#endif
- }
+ sema_down (&done[i]);
printf ("Multilevel feedback queue scheduler test done.\n");
}
printf ("Multilevel feedback queue scheduler test done.\n");
}
@@
-73,7
+70,7
@@
cpu_thread (void *sema_)
lock_release (&lock);
}
lock_release (&lock);
}
- printf ("CPU bound thread finished in %"PRI
64d
" ticks.\n",
+ printf ("CPU bound thread finished in %"PRI
d64
" ticks.\n",
timer_elapsed (start));
sema_up (sema);
timer_elapsed (start));
sema_up (sema);
@@
-94,7
+91,7
@@
io_thread (void *sema_)
#endif
}
#endif
}
- printf ("IO bound thread finished in %"PRI
64d
" ticks.\n",
+ printf ("IO bound thread finished in %"PRI
d64
" ticks.\n",
timer_elapsed (start));
sema_up (sema);
timer_elapsed (start));
sema_up (sema);
@@
-126,7
+123,7
@@
io_cpu_thread (void *sema_)
}
}
}
}
- printf ("Alternating IO/CPU thread finished in %"PRI
64d
" ticks.\n",
+ printf ("Alternating IO/CPU thread finished in %"PRI
d64
" ticks.\n",
timer_elapsed (start));
sema_up (sema);
timer_elapsed (start));
sema_up (sema);