Use everywhere the same pattern to handle fractional clock ticks

No behavior change; the code change is to make the maths easier to
proofread
This commit is contained in:
Alexandre Ratchov 2021-01-14 14:58:09 +01:00
parent 63d4639f9a
commit fd4c58aae7
1 changed files with 8 additions and 2 deletions

View File

@ -949,9 +949,15 @@ dev_onmove(struct dev *d, int delta)
* s->ops->onmove() may remove the slot
*/
snext = s->next;
pos = (long long)delta * s->round + s->delta_rem;
pos = s->delta_rem +
(long long)s->delta * d->round +
(long long)delta * s->round;
s->delta = pos / (int)d->round;
s->delta_rem = pos % d->round;
s->delta += pos / (int)d->round;
if (s->delta_rem < 0) {
s->delta_rem += d->round;
s->delta--;
}
if (s->delta >= 0)
s->ops->onmove(s->arg);
}