summaryrefslogtreecommitdiff
path: root/kern/sched_prim.c
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2015-07-25 01:46:53 +0200
committerJustus Winter <4winter@informatik.uni-hamburg.de>2015-08-28 15:47:56 +0200
commit46d2c1dda2df8f185278aad63ea51f61336e8e7a (patch)
tree3d7762d2089adc4801bd1c397b28f149b46bc69f /kern/sched_prim.c
parent0e17ccface304dac65efd86b3c6262afeecac05a (diff)
kern: new function `thread_sleep_lock'
* kern/sched_prim.c (thread_sleep_lock): New function. * kern/sched_prim.h (thread_sleep_lock): New delcaration.
Diffstat (limited to 'kern/sched_prim.c')
-rw-r--r--kern/sched_prim.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/kern/sched_prim.c b/kern/sched_prim.c
index 580ca43..a06cc92 100644
--- a/kern/sched_prim.c
+++ b/kern/sched_prim.c
@@ -458,6 +458,24 @@ void thread_sleep(
}
/*
+ * thread_sleep_lock:
+ *
+ * Cause the current thread to wait until the specified event
+ * occurs. The specified lock is unlocked before releasing
+ * the cpu. (This is a convenient way to sleep without manually
+ * calling assert_wait).
+ */
+void thread_sleep_lock(
+ event_t event,
+ lock_t lock,
+ boolean_t interruptible)
+{
+ assert_wait(event, interruptible); /* assert event */
+ lock_done(lock); /* release the lock */
+ thread_block((void (*)()) 0); /* block ourselves */
+}
+
+/*
* thread_bind:
*
* Force a thread to execute on the specified processor.