-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kernel/hil/time,capsules/alarm: pad Ticks to 32 bit for predictable w…
…rapping This change introduces new APIs on the `Ticks` trait of `kernel/src/hil/time.rs` which allow consumers of this type to know the underlying timer's actual ticks width (may be less than 32 bit), and to right-pad Ticks values to wrap at exactly `(2 ** 32) - 1` ticks. By exposing this shifted Ticks value, and an appropriately scaled tick frequency, to userspace, Tock finally conforms to assumptions made in userspace long ago: The client should not assume anything about the underlying clock used by an implementation other than that it is running at sufficient frequency to deliver at least millisecond granularity and that it is a 32-bit clock (i.e. it will wrap at 2^32 clock ticks). This predictable timer interface can allow userspace to build timer infrastructure that can schedule alarms or sleep for longer than `2 ** Timer Width` ticks. Apart from now conforming to libtock-c's expectations, by scaling both timer and frequency this change should not break any existing userspace applications (apart from triggering an otherwise unrelated bug in libtock-c's virtual alarms). It does modify code for which a relevant TRD (105) exists, but that TRD is still in draft state. Co-authored-by: tylerp <[email protected]>
- Loading branch information
1 parent
86987da
commit 45c54a2
Showing
2 changed files
with
173 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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