summaryrefslogtreecommitdiff
path: root/kern/mutex/mutex_plain_i.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-08-27 16:48:54 +0200
committerRichard Braun <rbraun@sceen.net>2017-08-27 16:48:54 +0200
commitc32a06eae07bd0bc0b4017ea5286b91d6518ec7f (patch)
tree73bfb9b6ba05e4b7ea6d30ba83e7089095cec217 /kern/mutex/mutex_plain_i.h
parent791a6563cd955f59e04084f1fc20aadbbc6ae25f (diff)
kern/mutex/mutex_plain: implement timed waits
Diffstat (limited to 'kern/mutex/mutex_plain_i.h')
-rw-r--r--kern/mutex/mutex_plain_i.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/kern/mutex/mutex_plain_i.h b/kern/mutex/mutex_plain_i.h
index 4f112b89..58e565ed 100644
--- a/kern/mutex/mutex_plain_i.h
+++ b/kern/mutex/mutex_plain_i.h
@@ -24,6 +24,7 @@
#endif
#include <assert.h>
+#include <stdint.h>
#include <kern/atomic.h>
#include <kern/error.h>
@@ -71,6 +72,7 @@ mutex_plain_unlock_fast(struct mutex *mutex)
}
void mutex_plain_lock_slow(struct mutex *mutex);
+int mutex_plain_timedlock_slow(struct mutex *mutex, uint64_t ticks);
void mutex_plain_unlock_slow(struct mutex *mutex);
/*
@@ -98,6 +100,20 @@ mutex_impl_lock(struct mutex *mutex)
}
}
+static inline int
+mutex_impl_timedlock(struct mutex *mutex, uint64_t ticks)
+{
+ int error;
+
+ error = mutex_plain_lock_fast(mutex);
+
+ if (unlikely(error)) {
+ error = mutex_plain_timedlock_slow(mutex, ticks);
+ }
+
+ return error;
+}
+
static inline void
mutex_impl_unlock(struct mutex *mutex)
{