+/*
+ * thread_sleep_mutex_deadline:
+ *
+ * Cause the current thread to wait until the specified event
+ * (or deadline) occurs. The specified mutex is unlocked before
+ * releasing the cpu. The mutex will be re-acquired before returning.
+ *
+ * JMM - Add hint to make sure mutex is available before rousting
+ */
+wait_result_t
+thread_sleep_mutex_deadline(
+ event_t event,
+ mutex_t *mutex,
+ uint64_t deadline,
+ wait_interrupt_t interruptible)
+{
+ wait_result_t res;
+
+ res = assert_wait(event, interruptible);
+ if (res == THREAD_WAITING) {
+ mutex_unlock(mutex);
+ thread_set_timer_deadline(deadline);
+ res = thread_block(THREAD_CONTINUE_NULL);
+ if (res != THREAD_TIMED_OUT)
+ thread_cancel_timer();
+ mutex_lock(mutex);
+ }
+ return res;
+}
+
+/*
+ * thread_sleep_lock_write:
+ *
+ * Cause the current thread to wait until the specified event
+ * occurs. The specified (write) lock is unlocked before releasing
+ * the cpu. The (write) lock will be re-acquired before returning.
+ *
+ * JMM - Add hint to make sure mutex is available before rousting
+ */
+wait_result_t
+thread_sleep_lock_write(
+ event_t event,
+ lock_t *lock,
+ wait_interrupt_t interruptible)
+{
+ wait_result_t res;
+
+ res = assert_wait(event, interruptible);
+ if (res == THREAD_WAITING) {
+ lock_write_done(lock);
+ res = thread_block(THREAD_CONTINUE_NULL);
+ lock_write(lock);
+ }
+ return res;
+}
+
+
+/*
+ * thread_sleep_funnel:
+ *
+ * Cause the current thread to wait until the specified event
+ * occurs. If the thread is funnelled, the funnel will be released
+ * before giving up the cpu. The funnel will be re-acquired before returning.
+ *
+ * JMM - Right now the funnel is dropped and re-acquired inside
+ * thread_block(). At some point, this may give thread_block() a hint.
+ */
+wait_result_t
+thread_sleep_funnel(
+ event_t event,
+ wait_interrupt_t interruptible)
+{
+ wait_result_t res;
+
+ res = assert_wait(event, interruptible);
+ if (res == THREAD_WAITING) {
+ res = thread_block(THREAD_CONTINUE_NULL);
+ }
+ return res;
+}
+