summaryrefslogtreecommitdiff
path: root/kern/mutex/mutex_adaptive_i.h
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2017-08-27 16:52:41 +0200
committerRichard Braun <rbraun@sceen.net>2017-08-27 16:52:41 +0200
commita509d86280d14b435640c446d81d85e53fd866e9 (patch)
tree4ff6c9f2f836852d971315f59b1815d287a3a89d /kern/mutex/mutex_adaptive_i.h
parentc32a06eae07bd0bc0b4017ea5286b91d6518ec7f (diff)
kern/mutex/mutex_adaptive: implement timed waits
Diffstat (limited to 'kern/mutex/mutex_adaptive_i.h')
-rw-r--r--kern/mutex/mutex_adaptive_i.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/kern/mutex/mutex_adaptive_i.h b/kern/mutex/mutex_adaptive_i.h
index b9952ec6..be822c24 100644
--- a/kern/mutex/mutex_adaptive_i.h
+++ b/kern/mutex/mutex_adaptive_i.h
@@ -78,6 +78,7 @@ mutex_adaptive_unlock_fast(struct mutex *mutex)
}
void mutex_adaptive_lock_slow(struct mutex *mutex);
+int mutex_adaptive_timedlock_slow(struct mutex *mutex, uint64_t ticks);
void mutex_adaptive_unlock_slow(struct mutex *mutex);
/*
@@ -105,6 +106,20 @@ mutex_impl_lock(struct mutex *mutex)
}
}
+static inline int
+mutex_impl_timedlock(struct mutex *mutex, uint64_t ticks)
+{
+ int error;
+
+ error = mutex_adaptive_lock_fast(mutex);
+
+ if (unlikely(error)) {
+ error = mutex_adaptive_timedlock_slow(mutex, ticks);
+ }
+
+ return error;
+}
+
static inline void
mutex_impl_unlock(struct mutex *mutex)
{