On hardware platforms with a variable-duration one-shot timer interrupt, the timer interrupt can be configured to fire at the next deadline on the timer wheel, rather than at a fixed interval. This is more efficient than advancing the wheel every time a periodic timer fires, as in many cases, most of those interrupts may not correspond to the deadline of any pending timer. It also permits more precise timing, as a periodic timer interval may "overshoot" the deadline of a particular sleep future. Currently, the maitake::time::Timer API doesn't expose the deadline of the next firing timer, though, so it's not currently possible to implement this pattern.
This branch changes the Timer::advance, Timer::advance_ticks, Timer::force_advance, and Timer::force_advance_ticks methods to return a Turn structure, which described what occurred while advancing the timer. This is very similar to the Tick structure returned by Scheduler::tick. Among other data, the Turn struct contains the time until the next expiring deadline. This can be used to configure the hardware timer in oneshot mode.
We could probably also add a method on Timer to just return the next deadline without advancing the wheel. However, this would currently require acquiring the lock. Since advancing the timer already requires locking the wheel, and we will generally care about the next deadline when we have just advanced the wheel, it seems more efficient to return it from advance (and friends), without re-locking.
On hardware platforms with a variable-duration one-shot timer interrupt, the timer interrupt can be configured to fire at the next deadline on the timer wheel, rather than at a fixed interval. This is more efficient than advancing the wheel every time a periodic timer fires, as in many cases, most of those interrupts may not correspond to the deadline of any pending timer. It also permits more precise timing, as a periodic timer interval may "overshoot" the deadline of a particular sleep future. Currently, the
maitake::time::Timer
API doesn't expose the deadline of the next firing timer, though, so it's not currently possible to implement this pattern.This branch changes the
Timer::advance
,Timer::advance_ticks
,Timer::force_advance
, andTimer::force_advance_ticks
methods to return aTurn
structure, which described what occurred while advancing the timer. This is very similar to theTick
structure returned byScheduler::tick
. Among other data, theTurn
struct contains the time until the next expiring deadline. This can be used to configure the hardware timer in oneshot mode.We could probably also add a method on
Timer
to just return the next deadline without advancing the wheel. However, this would currently require acquiring the lock. Since advancing the timer already requires locking the wheel, and we will generally care about the next deadline when we have just advanced the wheel, it seems more efficient to return it fromadvance
(and friends), without re-locking.Closes #440