X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Ftests%2Fthreads%2Fpriority-donate-nest.c;h=71cf8a9186db979a14ae224ccd809cf2f21754bf;hb=fd36e1fee6a7f98bfbc13aa20f0ee7d3aeab72ef;hp=a7b919c90b276cf049bdab81598687e40a11f4e6;hpb=0b877ed0d174985b620fdf3be1183ac09d7c55fd;p=pintos-anon diff --git a/src/tests/threads/priority-donate-nest.c b/src/tests/threads/priority-donate-nest.c index a7b919c..71cf8a9 100644 --- a/src/tests/threads/priority-donate-nest.c +++ b/src/tests/threads/priority-donate-nest.c @@ -1,5 +1,9 @@ -/* Problem 1-3: Priority Scheduling tests. - +/* Low-priority main thread L acquires lock A. Medium-priority + thread M then acquires lock B then blocks on acquiring lock A. + High-priority thread H then blocks on acquiring lock B. Thus, + thread H donates its priority to M, which in turn donates it + to thread L. + Based on a test originally submitted for Stanford's CS 140 in winter 1999 by Matt Franklin , Greg Hutchins , Yu Ping Hu @@ -39,15 +43,15 @@ test_priority_donate_nest (void) locks.a = &a; locks.b = &b; - thread_create ("medium", PRI_DEFAULT - 1, medium_thread_func, &locks); + thread_create ("medium", PRI_DEFAULT + 1, medium_thread_func, &locks); thread_yield (); msg ("Low thread should have priority %d. Actual priority: %d.", - PRI_DEFAULT - 1, thread_get_priority ()); + PRI_DEFAULT + 1, thread_get_priority ()); - thread_create ("high", PRI_DEFAULT - 2, high_thread_func, &b); + thread_create ("high", PRI_DEFAULT + 2, high_thread_func, &b); thread_yield (); msg ("Low thread should have priority %d. Actual priority: %d.", - PRI_DEFAULT - 2, thread_get_priority ()); + PRI_DEFAULT + 2, thread_get_priority ()); lock_release (&a); thread_yield (); @@ -65,7 +69,7 @@ medium_thread_func (void *locks_) lock_acquire (locks->a); msg ("Medium thread should have priority %d. Actual priority: %d.", - PRI_DEFAULT - 2, thread_get_priority ()); + PRI_DEFAULT + 2, thread_get_priority ()); msg ("Medium thread got the lock."); lock_release (locks->a);