Real-time Simulations
Keeping simulation time aligned with wall time
A real-time simulation assigns each event in simulated time a target in elapsed wall time. The two timelines need a shared origin and a stated conversion rule. An event meets its deadline only if the required processing finishes by that mapped wall-time target.
Map the two clocks
Let the constant positive rate be simulated seconds advanced per wall second. From matching zero origins, divide a simulated timestamp by that rate to find its wall elapsed deadline. A rate above one gives less wall time for a fixed simulated interval; a rate below one gives more.
Use a monotonic elapsed-time clock to schedule and measure deadlines. A civil clock can jump when its displayed time is adjusted, even though elapsed processing time did not jump.
Check the work budget
For periodic steps, the tick budget is the wall interval allowed between successive deadlines. Add the durations of tasks that cannot overlap, then compare their total with that budget.
When sequential work takes longer than the wall interval on every step, backlog increases unless work is skipped or scheduling changes.
Compute the recurring overrun as work time minus budget, then multiply by the number of identical ticks when the initial lag is zero. This timing test says nothing by itself about the simulated model's statistical validity.
Worked example
Suppose a simulator advances 1.5 simulated seconds per wall second, with both clocks starting at zero. An event stamped 3.6 simulated seconds is due after 3.6 divided by 1.5, or 2.4 wall seconds.
If processing finishes at wall elapsed 2.48 seconds, its lateness is 2.48 minus 2.4, or 0.08 wall second.
The calculation uses a single shared origin and a constant rate. It compares a completion timestamp with the event's deadline, not with the simulated timestamp directly.
A simulator advances 2 simulated seconds per 1 wall second from the same zero origin. At what wall elapsed time is a simulated-time 12 s event due?
At a 1:1 simulation rate, each tick represents 50 ms of simulated time. Its required sequential computation takes 80 ms of wall time, with no skipped work or overlap. What happens if this continues?