mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 13:28:27 +00:00
zdtm/maps007: remove spinlocks from the test
Use futex for synchronization instead of spinning on atomic variables. Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
8ce7ef75ec
commit
e16f0976fc
@ -80,13 +80,12 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
if (child) {
|
if (child) {
|
||||||
futex_wait_while_gt(&shm->delta, 2 * MAX_DELTA);
|
futex_wait_while_gt(&shm->delta, 2 * MAX_DELTA);
|
||||||
futex_inc(&shm->delta);
|
futex_inc_and_wake(&shm->delta);
|
||||||
} else {
|
} else {
|
||||||
if (!futex_get(&shm->stop))
|
if (!futex_get(&shm->stop))
|
||||||
/* MAX_DELTA steps behind the parent */
|
futex_wait_while_lt(&shm->delta, MAX_DELTA);
|
||||||
while (futex_get(&shm->delta) < MAX_DELTA &&
|
|
||||||
!futex_get(&shm->stop));
|
if (futex_get(&shm->stop) && atomic_get(&shm->delta) == MAX_DELTA)
|
||||||
else if (atomic_get(&shm->delta) == 0)
|
|
||||||
break;
|
break;
|
||||||
futex_dec_and_wake(&shm->delta);
|
futex_dec_and_wake(&shm->delta);
|
||||||
}
|
}
|
||||||
@ -130,6 +129,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
/* stop the child */
|
/* stop the child */
|
||||||
futex_set(&shm->stop, 1);
|
futex_set(&shm->stop, 1);
|
||||||
|
futex_add_and_wake(&shm->delta, MAX_DELTA);
|
||||||
/* wait until the child will be in the same point */
|
/* wait until the child will be in the same point */
|
||||||
futex_wait_until(&shm->stop, 2);
|
futex_wait_until(&shm->stop, 2);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user