cyclictest: fix accumulating overruns in periodic timer mode
PATCH 1/1 cyclictest: fix accumulating overruns in periodic timer mode
When using a POSIX interval timer and an overrun occurs, a signal is always lost. From then on cyclictest would report all measurements as increased by N*period (where N is the number of overruns).
cyclictest can detect the overruns and adjust the expected time of the next tick accordingly.
Reported-by Marti Raudsepp <[email protected]>
Signed-off-by Michal Schmidt <[email protected]>
---
src/cyclictest/cyclictest.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
src/cyclictest/cyclictest.c +5 -0
@@ -713,6 +713,11 @@ void *timerthread(void *param) next.tv_sec += interval.tv_sec; next.tv_nsec += interval.tv_nsec; +if (par->mode ==MODE_CYCLIC ) { +int overrun_count =timer_getoverrun (timer); + next.tv_sec += overrun_count * interval.tv_sec; + next.tv_nsec += overrun_count * interval.tv_nsec; + }tsnorm (&next);if (par->max_cycles && par->max_cycles == stat->cycles)