In all the variants of the basic test for part 1-1, release the lock
[pintos-anon] / grading / threads / priority-donate-one.c
index e6382bdf9c911fd3786b0d0a49cbea6c5aa1fa9a..35f135c3d9ef6c372cd0af29f92aa2750a37705e 100644 (file)
@@ -26,7 +26,8 @@ test (void)
   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) 
@@ -39,25 +40,36 @@ test_donate_return (void)
 
   lock_init (&lock, "donor");
   lock_acquire (&lock);
-  thread_create ("acquire1", PRI_DEFAULT + 1, acquire_thread_func, &lock);
+  thread_create ("acquire1", PRI_DEFAULT + 1, acquire1_thread_func, &lock);
   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, acquire2_thread_func, &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
-acquire_thread_func (void *lock_) 
+acquire1_thread_func (void *lock_) 
 {
   struct lock *lock = lock_;
 
   lock_acquire (lock);
-  printf ("%s: got the lock\n", thread_name ());
+  printf ("acquire1: got the lock\n");
   lock_release (lock);
-  printf ("%s: done\n", thread_name ());
+  printf ("acquire1: done\n");
+}
+
+static void
+acquire2_thread_func (void *lock_) 
+{
+  struct lock *lock = lock_;
+
+  lock_acquire (lock);
+  printf ("acquire2: got the lock\n");
+  lock_release (lock);
+  printf ("acquire2: done\n");
 }