The call to wake_up() must be moved under the spin lock because
once we drop the lock 'tp' may no longer be valid because the
creating thread has exited. This basic thread implementation
was correct, this was simply a flaw in the test case.
spin_lock(&tp->tp_lock);
ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC);
tp->tp_rc = 1;
+ wake_up(&tp->tp_waitq);
spin_unlock(&tp->tp_lock);
- wake_up(&tp->tp_waitq);
thread_exit();
}
spin_lock(&tp->tp_lock);
ASSERT(tp->tp_magic == SPLAT_THREAD_TEST_MAGIC);
tp->tp_rc = 1;
+ wake_up(&tp->tp_waitq);
spin_unlock(&tp->tp_lock);
- wake_up(&tp->tp_waitq);
thread_exit();
/* The following code is unreachable when thread_exit() is
* working properly, which is exactly what we're testing */
spin_lock(&tp->tp_lock);
tp->tp_rc = 2;
- spin_unlock(&tp->tp_lock);
-
wake_up(&tp->tp_waitq);
+ spin_unlock(&tp->tp_lock);
}
static int