[CRIU] [PATCH 12/14] lock: add futex_inc_and_wake and futex_wait_while_lt

Andrey Vagin avagin at openvz.org
Fri Jan 11 04:22:43 EST 2013


Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 include/lock.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/lock.h b/include/lock.h
index cf976c2..cb3b5b8 100644
--- a/include/lock.h
+++ b/include/lock.h
@@ -70,6 +70,13 @@ static inline void futex_dec_and_wake(futex_t *f)
 	BUG_ON(sys_futex(&f->raw.counter, FUTEX_WAKE, INT_MAX, NULL, NULL, 0) < 0);
 }
 
+/* Decrement futex @f value and wake up all waiters */
+static inline void futex_inc_and_wake(futex_t *f)
+{
+	atomic_inc(&f->raw);
+	BUG_ON(sys_futex(&f->raw.counter, FUTEX_WAKE, INT_MAX, NULL, NULL, 0) < 0);
+}
+
 /* Plain increment futex @f value */
 static inline void futex_inc(futex_t *f) { atomic_inc(&f->raw); }
 
@@ -84,6 +91,10 @@ static inline void futex_wait_until(futex_t *f, u32 v)
 static inline void futex_wait_while_gt(futex_t *f, u32 v)
 { futex_wait_if_cond(f, v, <=); }
 
+/* Wait while futex @f value is greater than @v */
+static inline void futex_wait_while_lt(futex_t *f, u32 v)
+{ futex_wait_if_cond(f, v, >=); }
+
 /* Wait while futex @f value is @v */
 static inline void futex_wait_while(futex_t *f, u32 v)
 {
-- 
1.7.11.7



More information about the CRIU mailing list