From c32a06eae07bd0bc0b4017ea5286b91d6518ec7f Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sun, 27 Aug 2017 16:48:54 +0200 Subject: kern/mutex/mutex_plain: implement timed waits --- kern/mutex/mutex_plain_i.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'kern/mutex/mutex_plain_i.h') 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 +#include #include #include @@ -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) { -- cgit v1.2.3