Closed hawkw closed 8 months ago
(the way you say rdtsc
on RISC-V is mcycle
IIRC)
when creating a
Sleep
, do the following:
- immediately take
now()
(call thatt0
)- when the wheel lock has been acquired, take
now()
again (t1
)- subtract the time elapsed between
t0
andt1
from the sleep’s total duration when adding it to the wheel
it turns out i was kinda wrong about this part; as a Sleep
's deadline is already calculated immediately upon the sleep's creation, rather than after we get the wheel lock. so, inaccuracy is primarily just due to the fact that time "doesn't advance" while ticking the scheduler, in the current design, and not due to wheel lock delays.
- while we’re still holding the wheel lock after inserting the sleep, turn the wheel to
t1
we should still do this part, though (and i haven't done it yet).
now: Fn() -> u64
that doesrdtsc
or however it is you say “rdtsc” in ARM/RISC-V/etcNow
” impl that’s anAtomicU64
that only gets bumped when advancing the wheel (so you can still have the current thing, basically)Timer::now()
/global free fnnow()
that does nowSleep
, do the following:now()
(call thatt0
)now()
again (t1
)t0
andt1
from the sleep’s total duration when adding it to the wheelt1