On Tue, Jan 17, 2023 at 09:05:47AM +0000, Wagner Florian (DC-AE/ESW2) via
Linuxptp-users wrote:
> But for synchronizing the phase of the schedulers, it would be
> sufficient to synchronize the CLOCK_MONOTONICs relative to the cycle
> time of our tasks. So if we could for example define, that the
> offset between CLOCK_MONOTONIC and CLOCK_REALTIME can only be a
> multiple of our cycle time (eg. 1ms), this would be sufficient. Is
> there an option to do something like this?
The realtime/monotonic offset is handled in the kernel. Setting
CLOCK_REALTIME aka "wall clock" amounts to setting the variable
wall_to_monotonic in the timekeeper data structure.
There is no kernel interface to do what you what you propose.
> If this is not the case, what would happen if we hard (re-)set the
> offset during runtime of phc2sys to the closest multiple of our
> cycle time? Would phc2sys overwrite this
Yes, if allowed by the step_threshold configuration option.
> or would it just adjust the
> difference to the master clock that was introduced by this
> manipulation by adjusting the frequency of
> CLOCK_REALTIME/CLOCK_MONOTONIC?
This is the likely case, when step_threshold == 0.
> Do you have other recommendations to synchronize cyclic scheduling on linux
> systems with a monotonic time source?
Barring hacking the kernel, I think the easiest way would be to call
t1 = clock_gettime(CLOCK_REALTIME);
t2 = clock_gettime(CLOCK_MONOTONIC);
t3 = clock_gettime(CLOCK_REALTIME);
and figure the phase difference using (t1 + t3)/2 - t2
and then correct your monotonic timer so that it remains in phase with
CLOCK_REALTIME.
You only have to do this once at the beginning, then repeat whenever
CLOCK_REALTIME is set (you can detect that with the timer API).
HTH,
Richard
_______________________________________________
Linuxptp-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linuxptp-users