-/* Transitions a blocked thread T from its current state to the
- ready-to-run state. This is an error if T is not blocked.
- (Use thread_yield() to make the running thread ready.) */
+/* Puts the current thread to sleep. It will not be scheduled
+ again until awoken by thread_unblock().
+
+ This function must be called with interrupts turned off. It
+ is usually a better idea to use one of the synchronization
+ primitives in synch.h. */
+void
+thread_block (void)
+{
+ ASSERT (!intr_context ());
+ ASSERT (intr_get_level () == INTR_OFF);
+
+ thread_current ()->status = THREAD_BLOCKED;
+ schedule ();
+}
+
+/* Transitions a blocked thread T to the ready-to-run state.
+ This is an error if T is not blocked. (Use thread_yield() to
+ make the running thread ready.) */