From 8a4b2ab9b82129207bb9a45b2548daecc1857cae Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Sun, 2 Sep 2012 14:33:44 +0200 Subject: [PATCH] Remove unnecessary wait state from frequency estimator. Signed-off-by: Richard Cochran --- clock.c | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/clock.c b/clock.c index eb6a249..f01b070 100644 --- a/clock.c +++ b/clock.c @@ -199,6 +199,11 @@ static enum servo_state clock_no_adjust(struct clock *c) * By leaving out the path delay altogther, we can avoid the * error caused by our imperfect path delay measurement. */ + if (!f->ingress1) { + f->ingress1 = c->t2; + f->origin1 = tmv_add(c->t1, tmv_add(c->c1, c->c2)); + return state; + } f->count++; if (f->count < f->max_count) { return state; @@ -207,23 +212,24 @@ static enum servo_state clock_no_adjust(struct clock *c) * origin2 = c->t1 (+c->path_delay) + c->c1 + c->c2; */ origin2 = tmv_add(c->t1, tmv_add(c->c1, c->c2)); - if (f->ingress1) { - ratio = tmv_dbl(tmv_sub(origin2, f->origin1)) / - tmv_dbl(tmv_sub(c->t2, f->ingress1)); - pr_info("master offset %10lld s%d ratio %.9f path delay %10lld", - c->master_offset, state, ratio, c->path_delay); - fui = 1.0 + - (c->status.cumulativeScaledRateOffset + 0.0) / - (1ULL << 41); + ratio = tmv_dbl(tmv_sub(origin2, f->origin1)) / + tmv_dbl(tmv_sub(c->t2, f->ingress1)); + + pr_info("master offset %10lld s%d ratio %.9f path delay %10lld", + c->master_offset, state, ratio, c->path_delay); + + fui = 1.0 + + (c->status.cumulativeScaledRateOffset + 0.0) / + (1ULL << 41); + + pr_debug("peer/local %.9f", c->nrr); + pr_debug("fup_info %.9f", fui); + pr_debug("product %.9f", fui * c->nrr); + pr_debug("sum-1 %.9f", fui + c->nrr - 1.0); + pr_debug("master/local %.9f", ratio); + pr_debug("diff %+.9f", ratio - (fui + c->nrr - 1.0)); - pr_debug("peer/local %.9f", c->nrr); - pr_debug("fup_info %.9f", fui); - pr_debug("product %.9f", fui * c->nrr); - pr_debug("sum-1 %.9f", fui + c->nrr - 1.0); - pr_debug("master/local %.9f", ratio); - pr_debug("diff %+.9f", ratio - (fui + c->nrr - 1.0)); - } f->ingress1 = c->t2; f->origin1 = origin2; f->count = 0;