[Rpcemu] An idle loop?
rpcemu-list at howkins.me.uk
Sun Jan 31 12:15:18 PST 2010
>> > RISC OS also calls the SWI Portable_Idle when it is idle, so that's a
>> > potential mechanism to release some of the CPU. I can't remember if RPCEmu
>> > makes use of that.
I got inspired by this discussion, and threw together a quick module
which provides an absolutely minimal implementation of a Portable
module (RPCEmu currently makes no use of the Portable SWIs).
I then had a go at intercepting the Portable_Idle SWI, and sleeping
for a small amount of time (5ms) each time this is called.
The net result was the CPU usage would drop from 100% to ~5% after
5-10 seconds of being at the Desktop. The mouse remained reasonably
smooth, and the CPU usage would jump and down in proportion to the
activity in the emulator.
I haven't yet come to any conclusion about the impact on timing, but
we already require a module to compensate for clock drift.
The code is very rough-and-ready, though it looks like a reasonable
I think the long-term ideal would be to have separate threads for IO
devices that should wake up the CPU - keyboard, mouse, timers etc.
Currently many of the IO devices hang off the main CPU emulation loop.
We are working on tidying up the code for some of these devices -
hopefully we can decouple them more easily later.
More information about the Rpcemu