X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Fthreads%2Fp1-4.c;h=9d66a6f991b695033476542c94279f4bd7412fe9;hb=2d20cd50c41c87a90d49e4b7ace3d18b8fb34f23;hp=7c97e3798b077e98d34e7e44327d4a12541892c5;hpb=af42b7cc9c85b36ae0fa5da75e4dab80ac236059;p=pintos-anon diff --git a/src/tests/threads/p1-4.c b/src/tests/threads/p1-4.c index 7c97e37..9d66a6f 100644 --- 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 - 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 @@ -12,16 +13,15 @@ , Yu Ping Hu . Modified by arens and yph. */ -/* If you've implemented thread_join(), you can uncomment this. */ -/*#define THREAD_JOIN_IMPLEMENTED*/ - /* Uncomment to print progress messages. */ /*#define SHOW_PROGRESS*/ #include "threads/test.h" #include +#include #include "threads/synch.h" #include "threads/thread.h" +#include "devices/timer.h" static thread_func io_thread; static thread_func cpu_thread; @@ -30,10 +30,11 @@ static thread_func io_cpu_thread; 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]; tid_t tids[3]; + int i; printf ("\n" "Testing multilevel feedback queue scheduler.\n"); @@ -41,7 +42,7 @@ test (void) /* Start threads. */ for (i = 0; i < 3; i++) { - sema_init (&done[i], 0); + sema_init (&done[i], 0, names[i]); tids[i] = thread_create (names[i], PRI_DEFAULT, funcs[i], &done[i]); } @@ -76,7 +77,7 @@ cpu_thread (void *sema_) lock_release (&lock); } - printf ("CPU bound thread finished in %"PRI64d" ticks.\n", + printf ("CPU bound thread finished in %"PRId64" ticks.\n", timer_elapsed (start)); sema_up (sema); @@ -97,7 +98,7 @@ io_thread (void *sema_) #endif } - printf ("IO bound thread finished in %"PRI64d" ticks.\n", + printf ("IO bound thread finished in %"PRId64" ticks.\n", timer_elapsed (start)); sema_up (sema); @@ -129,7 +130,7 @@ io_cpu_thread (void *sema_) } } - printf ("Alternating IO/CPU thread finished in %"PRI64d" ticks.\n", + printf ("Alternating IO/CPU thread finished in %"PRId64" ticks.\n", timer_elapsed (start)); sema_up (sema);