Re: [chrony-dev] [PATCH] MacOS X - add drift removal |
[ Thread Index |
Date Index
| More chrony.tuxfamily.org/chrony-dev Archives
]
On Thu, Aug 06, 2015 at 04:57:43AM +1200, Bryan Christianson wrote:
> > @@ -119,7 +119,7 @@ start_adjust(void)
> > }
> >
> > UTI_DiffTimevalsToDouble(&elapsed, &T1, &T0);
> > - accrued_error = elapsed * current_freq;
> > + accrued_error = (elapsed + DRIFT_REMOVAL_INTERVAL / 2.0) * current_freq;
> >
> > adjust_required = - (accrued_error + offset_register);
>
> This changes the effective drift (as seen in tracking.log) from 18ppm to 6ppm but System time still hovers around -10us
If it changes the reported drift, it doesn't work as intended :). The
problem probably is that the the precorrection is not included in the
offset register and when the adjustment is stopped, the register will
be off by that value.
How about this?
--- a/sys_macosx.c
+++ b/sys_macosx.c
@@ -108,7 +108,7 @@ start_adjust(void)
{
struct timeval newadj, oldadj;
struct timeval T1;
- double elapsed, accrued_error;
+ double elapsed, accrued_error, expected_error;
double adjust_required;
double rounding_error;
double old_adjust_remaining;
@@ -120,8 +120,9 @@ start_adjust(void)
UTI_DiffTimevalsToDouble(&elapsed, &T1, &T0);
accrued_error = elapsed * current_freq;
+ expected_error = DRIFT_REMOVAL_INTERVAL / 2.0 * current_freq;
- adjust_required = - (accrued_error + offset_register);
+ adjust_required = - (accrued_error + offset_register + expected_error);
UTI_DoubleToTimeval(adjust_required, &newadj);
UTI_TimevalToDouble(&newadj, &adjustment_requested);
@@ -133,7 +134,7 @@ start_adjust(void)
UTI_TimevalToDouble(&oldadj, &old_adjust_remaining);
- offset_register = rounding_error - old_adjust_remaining;
+ offset_register = rounding_error - old_adjust_remaining - expected_error;
T0 = T1;
}
--
Miroslav Lichvar
--
To unsubscribe email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "unsubscribe" in the subject.
For help email chrony-dev-request@xxxxxxxxxxxxxxxxxxxx with "help" in the subject.
Trouble? Email listmaster@xxxxxxxxxxxxxxxxxxxx.