mirror of
https://gitlab.com/chrony/chrony.git
synced 2025-12-03 16:35:06 -05:00
refclock: improve precision with large offset
If a SHM or PHC refclock has a very large offset compensated by the offset option, or ignored with the pps or local option, there is a persistent loss of precision in the calculation of the sample offset using the double format. Rework the code to delay the calculation of the accumulated offset to include the specificed compensation and remaining correction of the system clock, where the calculation can be split to improve the precision. In the pps mode ignore integer seconds competely. The precision of the SOCK refclock is now limited to 1 nanosecond due to the extra double->timespec->double conversion.
This commit is contained in:
@@ -95,7 +95,6 @@ static int shm_poll(RCL_Instance instance)
|
||||
{
|
||||
struct timespec receive_ts, clock_ts;
|
||||
struct shmTime t, *shm;
|
||||
double offset;
|
||||
|
||||
shm = (struct shmTime *)RCL_GetDriverData(instance);
|
||||
|
||||
@@ -124,9 +123,8 @@ static int shm_poll(RCL_Instance instance)
|
||||
|
||||
UTI_NormaliseTimespec(&clock_ts);
|
||||
UTI_NormaliseTimespec(&receive_ts);
|
||||
offset = UTI_DiffTimespecsToDouble(&clock_ts, &receive_ts);
|
||||
|
||||
return RCL_AddSample(instance, &receive_ts, offset, t.leap);
|
||||
return RCL_AddSample(instance, &receive_ts, &clock_ts, t.leap);
|
||||
}
|
||||
|
||||
RefclockDriver RCL_SHM_driver = {
|
||||
|
||||
Reference in New Issue
Block a user