Commit 4798771c authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

lock: add a new primitive cr_wait_until_greater (v2)

to wait while a futex value bigger than defined value.

v2: s/bigger/greater
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Acked-by: 's avatarPavel Emelyanov <xemul@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent f00efadd
......@@ -63,6 +63,25 @@ static always_inline void cr_wait_until(u32 *v, u32 val)
}
}
/*
* Wait until futex @v value greater than @val
*/
static always_inline s32 cr_wait_until_greater(u32 *v, s32 val)
{
int ret;
s32 tmp;
while (1) {
tmp = *v;
if (tmp <= val)
break;
ret = sys_futex(v, FUTEX_WAIT, tmp, NULL, NULL, 0);
BUG_ON(ret < 0 && ret != -EWOULDBLOCK);
}
return tmp;
}
/*
* Wait while futex @v value is @val
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment