Add time server
This server should have the following functionality:
struct Tai {
nanoseconds: i128
}
struct Tick(u64);
enum DiscontinuityKind {
Suspend,
}
enum StartKind {
Boot,
Process,
Thread,
}
fn get_wall_boot() -> Tai
fn get_start(StartKind) -> Tick
fn get_now() -> Tick
fn get_ratio() -> (Tick, Tai)
fn get_next_discontinuity(Tick) -> (DiscontinuityKind, Range<Tick>)
TAI is the International Atomic Time.
See the extprim crate for the i128 type.
Some discussion:
<eternaleye> cmr: I've got ideas for filesystems, network stack stuff, ways of shimming stuff from seL4 to replace what might otherwise be daemons...
<eternaleye> Heck, I've even got Opinions on a set of time-handling APIs that might not suck
<eternaleye> Specifically, get start time (in wallclock), get ticks since start (monotonic + steady units of arbitrary fixed size), get tick/second ratio
<eternaleye> So for benchmarks you can just use the second function, and have values that when subtracted yield comparable intervals (steady)
<eternaleye> For reporting wall-clock time, measure with the second function, and as close as possible to displaying them to the user, call the first and third function, so you use consistent conversions and bases for all values
<eternaleye> Wall-clock interval time wouldn't need the first function - you'd subtract the tick intervals, then convert using the ratio
<eternaleye> Represent wall-clock time with TAI, and any other wall-clock time can be derived losslessly
<eternaleye> Smaller API than any OS I'm aware of, and allows more reliable handling of time to boot.
<eternaleye> Wall-clock corrections (like from NTP) would be applied to "when you booted", allowing ticks to remain monotonic and steady, while still being jump-free
<cmr> eternaleye: so my implementation plan ATM is to map a page into all consumers of the clock, which has the current-tick, the ratio, the start timestamp, and a ring buffer of discontinuities.
<cmr> with the ability to boop the clock keeping task to update the value.
<cmr> as well as a relatively low-frequency periodic timer that updates it