Repository navigation
rtapi: add opt-in virtual time for accelerated uspace simulation - #4893
Open
grenzland64 wants to merge 1 commit into
Open
grenzland64 wants to merge 1 commit into
grenzland64 wants to merge 1 commit into
Conversation
RTAPI_VIRTUAL_TIME=1 selects the POSIX non-realtime backend, skips the period sleep and makes rtapi_get_time() advance by exactly one period per cycle. It is off by default and limited to a single realtime thread. rtapi_app drops root and all capabilities in this mode, so hardware drivers that need privileged access cannot be loaded.
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.
Follow-up to the discussion in #4863. This is the small in-tree part I proposed there: an opt-in switch for uspace
rtapi_appthat lets a simulation run faster than real time. Everything specific to my use case (trace capture, gating of task and I/O) stays out of tree.What it does
With
RTAPI_VIRTUAL_TIME=1in the environment ofrtapi_app:rtapi_get_time()returns the thread start time plus exactly one period per completed cycle, so components see a jitter-free clock,rtapi_appdrops root and all capabilities at startup.Without the variable nothing changes; all new code paths are behind the check.
Limits
-EBUSY. Several threads would need a scheduler that orders them in virtual time; I left that out to keep the change small.hm2_ethover UDP or gpiod). If you would prefer an explicit refusal, I am happy to add one; suggestions for the right place are welcome.Testing
tests/virtual-time: every cycle sees exactly one period ontimedelta, more than 10 s of virtual time pass within 1 s of real time, and a second thread is refused.scripts/runtestsontests/virtual-time,tests/threads.*,tests/rtapi*,tests/hal*,tests/uspace: 35 of 36 pass. The one failure istests/halrmt, which needsnc; it was not installed in my build container, so I have not confirmed the cause.rtapi_appruns with the real uid and empty capability sets, and without it behaves as before.Not tested: RT-PREEMPT, Xenomai and RTAI hosts (the switch is meant to bypass them, but I could only run on a non-realtime kernel), and the documentation build for the new
ENVIRONMENTsection inrtapi_app.1.