๐ Time โ
The Time module provides the global runtime time source for Xila services.
Role in system โ
- Supplies current time to modules that stamp metadata (for example VFS attributes).
- Supplies uptime-like elapsed time since manager initialization.
- Acts as the canonical time source adapter for platform drivers.
Responsibilities and boundaries โ
In scope
- One-time manager initialization with a direct character device source.
get_current_time()andget_current_time_since_startup()query APIs.- Conversion between device byte payload and
core::time::Duration.
Out of scope
- Time synchronization protocols.
- Timezone/calendar policy.
- Multi-source clock arbitration.
Internal architecture โ
- Singleton manager in
OnceLock. Managerstores:device: &'static dyn DirectCharacterDevice,start_time: Durationcaptured at initialization.
- Current-time reads deserialize
Durationdirectly from device bytes.
Contract vs implementation
- Contract: callers get
Durationvalues and error on device/read failures. - Implementation: exact wire representation assumes device emits in-memory
Durationlayout expected by this build.
Lifecycle and execution model โ
- Platform provides time device implementation.
time::initialize(driver)captures startup timestamp.- Runtime callers use singleton for current time or elapsed since startup.
Data/control flow โ
- Read path: module caller -> time manager -> direct character device read ->
Duration. - Uptime path: current read - cached startup time.
Concurrency and synchronization model โ
- Manager state is immutable after initialization (device handle + start time).
- Read calls are lock-free in manager layer and depend on driver thread-safety guarantees.
Dependency model โ
- Upstream dependency: platform
DirectCharacterDeviceimplementation. - Downstream consumers: VFS, graphics tick callback, network time conversion.
Failure semantics and recovery behavior โ
- Initialization fails if initial time read fails.
- Runtime queries propagate device read failures as
time::Error. - No internal retry/backoff policy; callers decide recovery strategy.
Extension points โ
- Replace time source driver per target.
- Add higher-level synchronization layers above this module.
- Extend manager with optional monotonic/wall-clock source separation.
Known limitations and trade-offs โ
- Read-only API surface (no set-time operation in current module).
- Accuracy/monotonic behavior depends entirely on device implementation.
- Wire contract currently assumes compatible
Durationrepresentation at device boundary.