[CRIU] [PATCH CRIU 4/7] log-dirty: add microsecond sleep
Pavel Tikhomirov
ptikhomirov at virtuozzo.com
Thu Apr 7 06:28:43 PDT 2016
need this to be able to make pauses between iterations
Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
criu/dirty-logger.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/criu/dirty-logger.c b/criu/dirty-logger.c
index 5e8baa5..b17b2c2 100644
--- a/criu/dirty-logger.c
+++ b/criu/dirty-logger.c
@@ -4,6 +4,22 @@
#include "imgset.h"
+#define NSEC_PER_USEC 1000L
+#define USEC_PER_SEC 1000000L
+
+static int sleep_us(long us) {
+ struct timespec ts, rts;
+ ts.tv_sec = us / USEC_PER_SEC;
+ ts.tv_nsec = NSEC_PER_USEC * (us % USEC_PER_SEC);
+ while (nanosleep(&ts, &rts)) {
+ if (errno != EINTR)
+ return -1;
+ ts = rts;
+ }
+
+ return 0;
+}
+
#define CR_DIRTY_LOG "dirty-log.img"
void *dirty_logger_pthread(void *arg)
--
1.9.3
More information about the CRIU
mailing list