Closed dogtopus closed 6 months ago
There are also requests that need to be handled asynchronously (specifically any handlers that need to hand over the control to other threads while still be able to return results at a later time e.g. anything related to synchronization and things like Buzzer()
which delays or yields in syscall via OSSleep()
)
We need to change this proposal slightly to handle this preferably with asyncio and perhaps a separate emulator execution thread controlled by an asyncio event loop or alternatively a dedicated emulator event loop driven by callbacks (instead of a regular loop currently being used) with bare Coroutines triggered before executing guest code in a tick(), which also has the ability to end a tick() when it blocks on a domain-specific Future object for Scheduler.
Problem
For syscalls alone, #2 is a bit unclear of what it does, and after some elaboration, some parts of it don't make much sense and unnecessarily complicates things (like multilayer syscall handling and letting syscall handler's
process()
instead of using the callback object itself to handle host-guest data conversion).We also wanted to have a unified way to handle guest callbacks for both syscall and HLE modules. This proposal takes both use cases into account.
Proposal
Some basic points
GuestRequestHandler#register_guest_module()
on theHLEModuleHandler
instance.Workflow
Emulator context:
on_intr(2) or on_page_fault() -> set flag and signal the emulator to stop
Emulator context main loop:Modeling