Tuesday, 24 January 2023

Re: [Rpcemu] Patch to improve IOMD timer behaviour



On Fri, 30 Dec 2022 at 17:58, Jeffrey Lee <me@phlamethrower.co.uk> wrote:
Hi,

While working on some potential changes to the way RISC OS 5 uses the IOMD
timers, I spotted a couple of problems with the way RPCEmu emulates the
timers:

1. Reading from a timer can cause that timer to increment, causing it to
(a) go out of sync with the other timer, and (b) run much faster than real
time if you read from it in a loop

2. Under normal use, timers only increment in chunks of 4000 ticks,
limiting their usefulness (e.g. when latching & reading the counter to
time short sections of code or create a delay loop)

This patch should fix those two issues, by having the code get the current
time (from the QElapsedTimer) and process any pending ticks for both
timers whenever either of their GO or LAT registers are written.
gentimerirq() has also been updated so that it will use the QElapsedTimer
to work out how many ticks to apply instead of always applying 4000 ticks.

Obviously there are still improvements that could be made (e.g. more
precise timing of interrupts, synchronisation with other clocks in the
system), but this feels like a good step in the right direction. It's
enough to keep my code happy, and passes my quick "does it boot to
desktop" smoke test on various RISC OS 3.5 - 6 ROMs.

Let me know what you think!


Apologies for the slow response.

The code looks good, but I'd like to do some further testing.

Do you have suggestions for programs which would benefit from these more accurate timers?

Also, I'm aware that there's an intention to introduce an API for high-resolution timers to RISC OS, but I haven't been following this closely enough. Can you provide any update on the current state of this?

Thanks

Matthew

No comments:

Post a Comment