Skip to contentSkip to conversation

cyclictest: fix accumulating overruns in periodic timer mode

PATCH New Michal Schmidt 1 participant 1 message May 10, 2010

lore
Share & tools
lore
#0 lore raw

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.

---

 src/cyclictest/cyclictest.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
src/cyclictest/cyclictest.c +5 -0
index 3a7e752..6829d34 100644
@@ -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)