Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 05 Jun 2015 20:53:31 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Neel Natu <neelnatu@gmail.com>
Cc:        FreeBSD Current <freebsd-current@freebsd.org>
Subject:   Re: [CFR] Replacing while loops with proper division and multiplication
Message-ID:  <5571F02B.4080907@selasky.org>
In-Reply-To: <CAFgRE9HOmzv%2BSuzWjsKDtsgRJCP3LpGJEQmd02_V=35__OE91A@mail.gmail.com>
References:  <55714B26.6060802@selasky.org> <CAFgRE9HOmzv%2BSuzWjsKDtsgRJCP3LpGJEQmd02_V=35__OE91A@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/05/15 20:31, Neel Natu wrote:
>>> -       runs = 0;
>>> >>-       while (now >= state->nexthard) {
>>> >>-               state->nexthard += tick_sbt;
>>> >>-               runs++;
>>> >>-       }
>>> >>-       if (runs) {
>>> >>+       runs = (now - state->nexthard) / tick_sbt;
>>> >>+       if (runs > 0) {
>>> >>+               printf("R%d ", (int)runs);
>>> >>+               state->nexthard += tick_sbt * runs;
>>> >>                 hct = DPCPU_PTR(hardclocktime);
>>> >>                 *hct = state->nexthard - tick_sbt;
>>> >>                 if (fake < 2) {
> There is a difference in behavior in the two implementations when 'now
> == state->nexthard'. In the loop-based implementation this would end
> up with 'runs = 1' whereas in the division-based implementation it
> would end up with 'runs = 0'.
>
> I am not sure if this is intentional or just an oversight.

Hi Neel,

The nexthard is mainly updated in this piece of code. We can assume that 
"state->nexthard" is aligned to "ticks_sbt". If "state->nexthard % 
ticks_sbt == 0", is that still an issue?

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5571F02B.4080907>