summaryrefslogtreecommitdiff
path: root/kern
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-09-14 14:45:05 +0200
commit7e8ae7880a9e752884c7bcb674e6d1e7c1f325d4 (patch)
tree8e94ace3a108b3df4db3ee035f13170e675444e4 /kern
parent428d6a971cffaba40b0f8ea5f66c3a3e0c853e88 (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')
-rw-r--r--kern/sched_prim.c18
-rw-r--r--kern/sched_prim.h4
2 files changed, 22 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.
diff --git a/kern/sched_prim.h b/kern/sched_prim.h
index bb1865c..8b3f14b 100644
--- a/kern/sched_prim.h
+++ b/kern/sched_prim.h
@@ -71,6 +71,10 @@ extern void thread_sleep(
event_t event,
simple_lock_t lock,
boolean_t interruptible);
+extern void thread_sleep_lock(
+ event_t event,
+ lock_t lock,
+ boolean_t interruptible);
extern void thread_wakeup(void); /* for function pointers */
extern void thread_wakeup_prim(
event_t event,