summaryrefslogtreecommitdiff
path: root/kern/mutex.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-08-27 17:08:10 +0200
committerRichard Braun <rbraun@sceen.net>2017-08-27 17:08:10 +0200
commitdd43dd17d7fd82af9001a28709320dac7348f223 (patch)
tree9dad57b486fb505e473d7e6306cf8d26bbbbc6e0 /kern/mutex.h
parente395627038e10c6e966a141743b95d7c286b25bd (diff)
kern/mutex: add timed waits to the mutex interface
Diffstat (limited to 'kern/mutex.h')
-rw-r--r--kern/mutex.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/kern/mutex.h b/kern/mutex.h
index f192a70a..8cb7aaca 100644
--- a/kern/mutex.h
+++ b/kern/mutex.h
@@ -27,6 +27,8 @@
#error "only one of X15_MUTEX_PI and X15_MUTEX_ADAPTIVE may be defined"
#endif
+#include <stdint.h>
+
#if defined(X15_MUTEX_PI)
#include <kern/mutex/mutex_pi_i.h>
#elif defined(X15_MUTEX_ADAPTIVE)
@@ -77,6 +79,22 @@ mutex_lock(struct mutex *mutex)
}
/*
+ * Lock a mutex, with a time boundary.
+ *
+ * The time boundary is an absolute time in ticks.
+ *
+ * If successful, the mutex is locked, otherwise an error is returned.
+ * A mutex can only be locked once.
+ *
+ * This function may sleep.
+ */
+static inline int
+mutex_timedlock(struct mutex *mutex, uint64_t ticks)
+{
+ return mutex_impl_timedlock(mutex, ticks);
+}
+
+/*
* Unlock a mutex.
*
* The mutex must be locked, and must have been locked by the calling