Make thread_unblock() on a thread that isn't blocked an error.
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Sep 2004 21:11:40 +0000 (21:11 +0000)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 16 Sep 2004 21:11:40 +0000 (21:11 +0000)
src/threads/thread.c

index 5400f78de4d5f960c593d9bce1c86cc6603a64c6..90a4dcd6456f77423a781265737ed823ffbf3dc7 100644 (file)
@@ -183,7 +183,7 @@ thread_execute (const char *filename)
 #endif
 
 /* Transitions a blocked thread T from its current state to the
-   ready-to-run state.  If T is not blocked, there is no effect.
+   ready-to-run state.  This is an error if T is not blocked.
    (Use thread_yield() to make the running thread ready.) */
 void
 thread_unblock (struct thread *t) 
@@ -193,11 +193,9 @@ thread_unblock (struct thread *t)
   ASSERT (is_thread (t));
 
   old_level = intr_disable ();
-  if (t->status == THREAD_BLOCKED) 
-    {
-      list_push_back (&ready_list, &t->elem);
-      t->status = THREAD_READY;
-    }
+  ASSERT (t->status == THREAD_BLOCKED);
+  list_push_back (&ready_list, &t->elem);
+  t->status = THREAD_READY;
   intr_set_level (old_level);
 }