Repository navigation
feat(time): monotonic uptime + high-resolution clock for userland (#467) - #700
Merged
Merged
Conversation
- hal: uptime_ms() from the single BSP-only timer tick counter (monotonic,
SMP-safe) returning (ms, tick_hz).
- net/tcp: tcp_high_res_time() (calibrated TSC + kHz), routed via the baselined
module because boot_benchmark is not importable from hal/syscall.
- ObInfoClass::Uptime (46) = {uptime_ms, tick_hz}, HighResTime (47) = {tsc, tsc_khz}.
- libneodos: ob_uptime()/ob_uptime_ms()/ob_high_res_time().
- userbin/uptime: shows 'up Xd Xh Xm Xs (monotonic N ms, tick H Hz)'; -r raw ms,
-v high-res.
- timers: fix the HAL tick rate (1e9/TICK_INTERVAL_US -> 1e6/TICK_INTERVAL_US).
The period is 1000 us (1 kHz) but the rate was reported as 1 MHz, making
ticks->ms 1000x too small and service shutdown deadlines 1000x too long.
- tests: sys_uptime_monotonic, sys_highres_time_advances.
- docs: mark the monotonic-clock design Implemented.
Verified: QEMU 956/956; VirtualBox 956/956; guest 'uptime' ->
'up 0h 1m 22s (monotonic 82739 ms, tick 1000 Hz)' + high-res TSC.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #467.
What
Ring 3 gets a monotonic clock.
ObInfoClass::Uptime(46) returns{ uptime_ms: u64, tick_hz: u32, _pad }andHighResTime(47) returns{ tsc: u64, tsc_khz: u32, _pad }, matchingdocs/design/monotonic-clock-design.md.hal::uptime_ms()from the single BSP-only tick counter (monotonic, SMP-safe);net::tcp::tcp_high_res_time()(calibrated TSC) — routed through the baselined module becauseboot_benchmarkis not importable fromhal/syscall(same precedent astcp_deadline_from_ms). Query arms insyscall/ob/query/time.rs.ob_uptime()/ob_uptime_ms()/ob_high_res_time().up 0h 1m 22s (monotonic 82739 ms, tick 1000 Hz);-rraw ms;-vhigh-res TSC.timers::register_hal_hooksreported the tick rate as1e9/TICK_INTERVAL_US= 1 MHz although the period is 1000 us (1 kHz). Ticks-to-ms was 1000x too small andservices::deadline_from_nowproduced 1000x-too-long shutdown deadlines. Now1e6/TICK_INTERVAL_US= 1000 Hz.Acceptance (#467)
sys_uptime_monotonic,sys_highres_time_advances.sleep(ms)/ wait-with-timeout is tracked separately in KWAIT-TIMEOUT: timed waits (timeouts for ob_wait/poll/sleep) #283 (ob_wait gained finite socket timeouts in net: TCP real-NIC hardening, Ring 3 accept/wait and reliability #692/fix(sys): honor finite ob_wait timeouts for all objects (regression from #364) #696).Verification
neodev test: 956/956. VirtualBoxneodev test --backend virtualbox: 956/956.uptime->up 0h 1m 22s (monotonic 82739 ms, tick 1000 Hz);uptime -v->high-res: tsc=... tsc_khz=2707983.check-depsclean;check-irq-locksOK.Note
Full packaging requires the one-line NeoDev image-allowlist addition (
uptime), same asnetcli/netsrv/tcptest(separate repo).