summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranna-maria@glx-um.de <anna-maria@glx-um.de>2015-05-26 19:07:01 +0000
committerJohn Kacur <jkacur@redhat.com>2015-06-02 14:50:37 +0200
commit5265d5ed963bef595ca19dcfdedde1a48859cc2d (patch)
treeb0facfa07c725cf712b3265ae1f91c819088236e
parentcc0901e72d3e1a916fc97909e7c0c73264b61438 (diff)
downloadrt-tests-5265d5ed963bef595ca19dcfdedde1a48859cc2d.tar.gz
cyclictest: Ensure that next wakeup time is never in the past
The calculated next wakeup time is already in the past, if the latency is longer than the interval. Thereby latency is detected that does not correspond to latency caused by the system but by cyclictest itself. Force forward the next wakeup time past now. Signed-off-by: Anna-Maria Gleixner <anna-maria@glx-um.de> Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r--src/cyclictest/cyclictest.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index 38525d4..95bdfc3 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -369,6 +369,12 @@ static inline void tsnorm(struct timespec *ts)
}
}
+static inline int tsgreater(struct timespec *a, struct timespec *b)
+{
+ return ((a->tv_sec > b->tv_sec) ||
+ (a->tv_sec == b->tv_sec && a->tv_nsec > b->tv_nsec));
+}
+
static inline int64_t calcdiff(struct timespec t1, struct timespec t2)
{
int64_t diff;
@@ -949,6 +955,12 @@ void *timerthread(void *param)
}
tsnorm(&next);
+ while (tsgreater(&now, &next)) {
+ next.tv_sec += interval.tv_sec;
+ next.tv_nsec += interval.tv_nsec;
+ tsnorm(&next);
+ }
+
if (par->max_cycles && par->max_cycles == stat->cycles)
break;
}