X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Fthreads%2Fpriority-donate-multiple.c;h=e1bccbdb4b567baef5c1767173ff9271aeda74c9;hb=a85e535e696138054a7b461ea8072f0d76c5b668;hp=012022b2e47b9bdfc4ba969827b6775c21b73ab4;hpb=4ebf33908a571a7cde93fe618902b044e3633cdf;p=pintos-anon diff --git a/src/tests/threads/priority-donate-multiple.c b/src/tests/threads/priority-donate-multiple.c index 012022b..e1bccbd 100644 --- a/src/tests/threads/priority-donate-multiple.c +++ b/src/tests/threads/priority-donate-multiple.c @@ -1,10 +1,13 @@ -/* Problem 1-3: Priority Scheduling tests. - +/* The main thread acquires locks A and B, then it creates two + higher-priority threads. Each of these threads blocks + acquiring one of the locks and thus donate their priority to + the main thread. The main thread releases the locks in turn + and relinquishes its donated priorities. + Based on a test originally submitted for Stanford's CS 140 in - winter 1999 by by Matt Franklin - , Greg Hutchins - , Yu Ping Hu . - Modified by arens. */ + winter 1999 by Matt Franklin , + Greg Hutchins , Yu Ping Hu + . Modified by arens. */ #include #include "tests/threads/tests.h" @@ -32,18 +35,18 @@ test_priority_donate_multiple (void) lock_acquire (&a); lock_acquire (&b); - thread_create ("a", PRI_DEFAULT - 1, a_thread_func, &a); + thread_create ("a", PRI_DEFAULT + 1, a_thread_func, &a); msg ("Main thread should have priority %d. Actual priority: %d.", - PRI_DEFAULT - 1, thread_get_priority ()); + PRI_DEFAULT + 1, thread_get_priority ()); - thread_create ("b", PRI_DEFAULT - 2, b_thread_func, &b); + thread_create ("b", PRI_DEFAULT + 2, b_thread_func, &b); msg ("Main thread should have priority %d. Actual priority: %d.", - PRI_DEFAULT - 2, thread_get_priority ()); + PRI_DEFAULT + 2, thread_get_priority ()); lock_release (&b); msg ("Thread b should have just finished."); msg ("Main thread should have priority %d. Actual priority: %d.", - PRI_DEFAULT - 1, thread_get_priority ()); + PRI_DEFAULT + 1, thread_get_priority ()); lock_release (&a); msg ("Thread a should have just finished.");