[FEATURE] Provide clock observations and owned sleep #18

Open
opened 2026-10-29 12:59:31 +01:00 by erikinkinen · 2 comments
Owner

Problem and motivation

C programs need clock observations and sleep through their admitted process bindings. Boot-relative counters, synthetic dates and elapsed time cannot stand in for Unix time or CPU usage.

Proposed behavior and scope

Provide namespaced clock_gettime, clock_getres, time, timespec_get, nanosleep, clock_nanosleep, sleep and thrd_sleep calls, with a signed 64-bit time scalar and explicit EriX timespec layout. Supply the C header, Rust core, selected native runtime, Posixd mediation and a real C workload.

Use calibrated monotonic time and source-qualified realtime. Report actual clock resolution separately from counter units and RTC accuracy. Relative waits measure elapsed duration; absolute realtime waits must account for accepted wall-clock changes. Keep the complete C11 and selected upstream interface inventory visible, including calendar conversion, timezone, conventional aliases and CPU-accounting gaps.

Authority, security and reliability

Use only the caller's existing optional Clock binding through Posixd. Add no service discovery, fallback capability, clock-setting operation or default grant. Keep unsupported CPU clocks explicit rather than returning elapsed time.

Retain each original sample, wait and cancellation operation, its backing storage and independent cleanup result until retirement. Check source, framing and correlation before publishing output. Define NULL, overlap, range, errno and interruption/remainder rules for every call; snapshot aliased inputs and prevent publication after their borrow ends. Preserve old wire contracts and coordinate any additive version change across producers and consumers.

Acceptance criteria

  • Specify all eight interfaces, error/output precedence, availability and interruption rules against primary specifications; map the remaining required C11 and upstream calls.
  • Implement truthful observations and real relative/absolute sleeps, including resolution metadata and wall-clock rebasing.
  • Cover boundary values, malformed replies, missing grants, concurrent calls, interruption, cancellation, partial failure and uncertain cleanup with independent controls.
  • Execute the original C workload through an explicitly clock-enabled native process and VM profile; preserve existing byte-only profiles.
  • Publish the header, inline Rustdoc, API reference, component contracts and technical manual together with coherent source selection.

Alternatives and tradeoffs

Busy waiting, global backend discovery and synthetic success hide missing mechanisms or broaden authority. Reusing the existing Clock binding keeps policy with the process owner. Calendar, floating-point and CPU-accounting interfaces need their own complete contracts; this declared set does not imply complete libc coverage.

Tracking and rollout

Extend the C runtime and compatibility ABI alongside toolchain integration and the phase tracker. Settle the interface and provider contracts before implementation, then publish the library, mediation, original-source C consumer and manual changes in dependency order. Keep native execution and complete in-EriX builds as separate acceptance requirements.

## Problem and motivation C programs need clock observations and sleep through their admitted process bindings. Boot-relative counters, synthetic dates and elapsed time cannot stand in for Unix time or CPU usage. ## Proposed behavior and scope Provide namespaced clock_gettime, clock_getres, time, timespec_get, nanosleep, clock_nanosleep, sleep and thrd_sleep calls, with a signed 64-bit time scalar and explicit EriX timespec layout. Supply the C header, Rust core, selected native runtime, Posixd mediation and a real C workload. Use calibrated monotonic time and source-qualified realtime. Report actual clock resolution separately from counter units and RTC accuracy. Relative waits measure elapsed duration; absolute realtime waits must account for accepted wall-clock changes. Keep the complete C11 and selected upstream interface inventory visible, including calendar conversion, timezone, conventional aliases and CPU-accounting gaps. ## Authority, security and reliability Use only the caller's existing optional Clock binding through Posixd. Add no service discovery, fallback capability, clock-setting operation or default grant. Keep unsupported CPU clocks explicit rather than returning elapsed time. Retain each original sample, wait and cancellation operation, its backing storage and independent cleanup result until retirement. Check source, framing and correlation before publishing output. Define NULL, overlap, range, errno and interruption/remainder rules for every call; snapshot aliased inputs and prevent publication after their borrow ends. Preserve old wire contracts and coordinate any additive version change across producers and consumers. ## Acceptance criteria - [ ] Specify all eight interfaces, error/output precedence, availability and interruption rules against primary specifications; map the remaining required C11 and upstream calls. - [ ] Implement truthful observations and real relative/absolute sleeps, including resolution metadata and wall-clock rebasing. - [ ] Cover boundary values, malformed replies, missing grants, concurrent calls, interruption, cancellation, partial failure and uncertain cleanup with independent controls. - [ ] Execute the original C workload through an explicitly clock-enabled native process and VM profile; preserve existing byte-only profiles. - [ ] Publish the header, inline Rustdoc, API reference, component contracts and technical manual together with coherent source selection. ## Alternatives and tradeoffs Busy waiting, global backend discovery and synthetic success hide missing mechanisms or broaden authority. Reusing the existing Clock binding keeps policy with the process owner. Calendar, floating-point and CPU-accounting interfaces need their own complete contracts; this declared set does not imply complete libc coverage. ## Tracking and rollout Extend the [C runtime](https://git.erikinkinen.fi/erix/lib-cstd/issues/1) and [compatibility ABI](https://git.erikinkinen.fi/erix/lib-posixabi/issues/1) alongside [toolchain integration](https://git.erikinkinen.fi/erix/integration/issues/7) and the [phase tracker](https://git.erikinkinen.fi/erix/integration/issues/65). Settle the interface and provider contracts before implementation, then publish the library, mediation, original-source C consumer and manual changes in dependency order. Keep native execution and complete in-EriX builds as separate acceptance requirements.
Author
Owner

Calibrated clock resolution and UTC waits are implemented in Kernel, Timed and lib-time, with matching IPC codecs and manual contracts. UTC waits retain the original target across wall-clock changes and complete after a fresh qualified observation and timer retirement. Integration selects the coordinated revisions. The C entry points, compatibility bridge and guest acceptance remain open.

Calibrated clock resolution and UTC waits are implemented in [Kernel](https://git.erikinkinen.fi/erix/kernel/commit/364fd955ed260593afaed5e538ad1cfa0381c639), [Timed](https://git.erikinkinen.fi/erix/timed/commit/bb43a7d2ec0c0a157ca6a20b5d0a2696e9c30e01) and [lib-time](https://git.erikinkinen.fi/erix/lib-time/commit/347d326e06cffddea2f12edfc9b7528ee17db12b), with matching IPC codecs and [manual contracts](https://git.erikinkinen.fi/erix/docs/commit/944a7ae0e493cb99e86b6cddeab23692c689b8af). UTC waits retain the original target across wall-clock changes and complete after a fresh qualified observation and timer retirement. [Integration](https://git.erikinkinen.fi/erix/integration/commit/49b0cd72dfb47675b3177fcc3956576ccdf0e6a4) selects the coordinated revisions. The C entry points, compatibility bridge and guest acceptance remain open.
Author
Owner

All eight namespaced time/sleep calls now have the mediated bridge and an opt-in workload linking the original C probe. Clock observation, wait and cancellation retain their original callers until retirement; existing profiles gain no Clock grant. Calendar, current-zone, CPU-accounting and conventional interfaces remain separate work.

All eight namespaced time/sleep calls now have the [mediated bridge](https://git.erikinkinen.fi/erix/posixd/commit/8765b7c26a82dd5fba4bad709df2d611c1556e5b) and an [opt-in workload](https://git.erikinkinen.fi/erix/integration/commit/6019db1a2464b8c98332def75f3f530c8acf27e6) linking the original C probe. Clock observation, wait and cancellation retain their original callers until retirement; existing profiles gain no Clock grant. Calendar, current-zone, CPU-accounting and conventional interfaces remain separate work.
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:34:41 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/lib-cstd#18
No description provided.