Expand description
This service’s own execution: giving up the CPU, waiting, and what time it is.
§Waiting is not the same as sleeping
The functions here wait on the CLOCK, and that makes them the wrong tool for waiting on another
service. Commandment VIII: wait on the truth, not on time. If you are sleeping because a peer
might not be ready yet, you have written a race that passes on your machine - wait for the thing
itself (crate::ipc::recv_within, a reply, an interrupt), and let it tell you.
What a sleep IS for: pacing something that has no event to wait on. A poll of an external device, a retry after congestion, a display that should not repaint faster than anyone can read.
Structs§
- Datetime
- Wall-clock date/time read from the hardware RTC, fully decoded (binary,
24-hour). See
ServiceContext::datetime.
Enums§
- Clock
Source - Where a wall-clock reading came from. Reported alongside the time so a displayed timestamp says what it is standing on: a local hardware clock, a network correction, or nothing (§26.4 - a fallback chain is mechanism while its choice is visible, and magic when it is not).
Constants§
- AUTHORITIES
- The kernel’s fixed authorities: (resource id, contract name, what it allows) - for naming a capability. THE KERNEL’S FIXED AUTHORITIES, by resource id: (id, the name a contract uses, what it lets a task do).
Functions§
- clock_
is_ set - Whether the
timeservice’s clock is worth showing as a date at all. - clock_
source - Where the wall clock came from, so a displayed timestamp can say what it stands on.
- core_id
- Which core this service is running on.
- datetime
- The HARDWARE real-time clock as calendar fields (InspectKernel query 11), with
Datetime::epoch_secsto turn it into epoch seconds. - epoch_
secs_ monotonic - Seconds that never go backwards (InspectKernel query 17).
- hw_
random - A random 32-bit word from the hardware (InspectKernel query 19), or
Noneon a machine whose port exposes no hardware random source. Ungated: entropy confers no authority. - sleep_
ms - Sleep for
msmilliseconds. - sleep_
quantum - Sleep for one scheduler quantum, parked: the shortest sleep there is.
- sleep_
ticks - Sleep for
ticksof the countercrate::driver::wait::ticksreads. - sleep_
us - Sleep for
usmicroseconds, at the kernel’s resolution. - uptime_
secs - Seconds since this machine booted.
- wall_
clock - The
timeservice’s clock: epoch seconds, and where they came from (clock_sourceexplains the four answers).Nonewhen there is no clock ortimedid not answer, which oblige a caller to the same thing: not to treat any number as the date. - yield_
now - Give up the rest of this quantum.