David Gibbs wrote:
Evan Hillas <> evanh@clear.net.nz> > wrote:
Maybe a change to CLOCK_MONOTIC is in order where it will not perform
any accumulating compensation.CLOCK_MONOTONIC doesn’t do any accumulating compensation. The compensation
is done on the boot time.
That is an additional correction that doesn’t affect CLOCK_MONOTIC, it’s not the one I’m interested in.
The app’s request gets rounded to the
nearest integral interrupt period and stays that way until it’s stopped
or the interrupt period is adjusted.I don’t think we can do that, round the applications request that way. If
the application wants rounding, it needs to do the rounding itself.
Let me reword that one. I meant have the OS choose the closest IRQ period based on rounding, which it already does, then no subsequent accumulation applied, which it currently does do to match the app’s real time request.
Currently the Posix based timer mechanism tries to fit a request over many events by accumulating the error for each event and at fairly regular intervals one extra or one less IRQ interval is applied to match the calculated real time of the app’s request. This method creates a “beat” as described in the tick-tock articles.
Of course the OS can round off the request. My concern has always been that, left to the application, there is no guarantee for the applications that their rounding will always match the OS’s internal IRQ interval constant(s).
So, the idea I had above, is add a mechanism that forces the request to the nearest integral of the IRQ interval.
But, as noted below, any such reliance on this level of regularity is doomed if subsequent ClockPeriod() adjustments are made so I don’t think adding this feature is a good idea any longer. Rather, I recommend adding a note to the timer documentation suggesting, that if such regularity is needed, of using alternative hardware timers and specialised hardware samplers/servo cards.
However, this idea is not ideal either. When it comes to interrupt
period adjustment such sampling systems are screwed unless the new period
is lucky enough to land on a multiple of the integral.Systems should NOT be adjusting the interrupt period on the fly. It should
be set once, as a system design consideration, shortly after boot time – and
before anything that will depend on it configures – and never be changed.
Really? Any root access program can change it at will. I would think that there is some sort of attempt by the OS to keep track of real time during such changes.
Evan