Hi, I am back again with some results:
I managed to create a clocksource driver that reads the monotonically upcounting counter of my hardware.
It is possible, to apply some sort of long time correction to the hardware counter. In fact, it does not count up the register every x-th tick or inserts another tick after x ticks, depending on if I want it to go slower of faster.
Now: I have put a 4 into the correction register which actually means that every fourth tick, the counter is not incremented. Indeed, this is a rather
hard correction, but good for testing.
On the command line I start this simple loop:
Code:
while `true`; do date; time sleep 20; done
which is pretty straight forward just printing the current date then sleep for 20 secs.
This is my result:
Code:
Mon Nov 25 21:19:22 CET 1929
real 0m20.025s
user 0m0.000s
sys 0m0.004s
Mon Nov 25 21:19:38 CET 1929
real 0m20.025s
user 0m0.000s
sys 0m0.004s
Mon Nov 25 21:19:54 CET 1929
real 0m20.022s
user 0m0.000s
sys 0m0.000s
Mon Nov 25 21:20:10 CET 1929
real 0m20.023s
user 0m0.000s
sys 0m0.004s
Mon Nov 25 21:20:26 CET 1929
real 0m20.025s
user 0m0.000s
sys 0m0.000s
Mon Nov 25 21:20:42 CET 1929
real 0m20.025s
user 0m0.000s
sys 0m0.000s
Obviously, the hardware
measures a real amount of time of 20 secs for the sleep. But the wall time actually only increases by approx. 16 secs every time.
Why that? I mean, when I measure externally, the elapsed real time is in fact 16 seconds, what makes sense, as I told the clock to go a lot slower.
But how the hack does Linux still keep track of the
outside wall time?
BTW: This also happens, if I do this whole thing only in software by changing the struct clocksource .mult value to the half of what it actually is. A
sleep 1 actually takes two seconds for real, but the date-command still maintains the outside wall time...