Implement cycle timer with fixed time grid [REVPI-4744]

With commit a3a234b9 ("Fix io cycle interval duration") the errorneous implementation of the cycle timer was corrected to provide a fix cycle interval. However this solution uses relative offsets to set the next timer expiration time which may result in slight deviations from a fixed time grid or even bigger shifts in case of missed cycles. If for example a cycle duration of 5 ms is specified the expiration times may be (starting from time 0): 0, 5, 10, 15 in the best case. But they may also be 0, 4, 11, 16 in case that the timer did not expire exactly at its last calculated expiration time. And in case of missed cycles it may even be 0, 4, 11, 16, (overlong cycle of 8 msec) 24, 29, ...

So use an absolute expiration time instead and calculate the next time to expire as an offset from a fixed starting point. With this the calculated expiration times are (starting from time 0): 0, 5, 10, 15, etc. In case of missed cycles it may be 0, 5, 10, 15, (overlong cycle) 25, 30, ...

While both solutions work for fixed cycle intervals, only the latter enforced fixed time grid which equals more the way that SPS works.

Signed-off-by: Lino Sanfilippo l.sanfilippo@kunbus.com

Merge request reports

Loading