axpbox
axpbox copied to clipboard
Typing characters on serial is slow
When you type a character, it takes a long time for it to arrive to the VM and be sent back to be printed.
This is caused by the inefficient implementation of Serial.cpp
, which waits 20 milliseconds for each cycle in the thread (if the sleep is removed, the delay disappears).
I was looking into this, but I'm unsure how to proceed code wise. Turning this mechanism inside out (events instead of polling) with this telnet socket (recv / read), I can't just hammer on callbacks to that flow.
Also how the data flows through this emulator, set write some memory, set an interrupt high, then wait for the cpu thread to do another cycle and trigger other components (keyboard for example), not quite sure if that can ever be fully removed. (The loop part I mean).
Some sort of event bus / pubsub with callbacks comes to mind, but is that a direction you want to look into, shall I try to put some effort in, let's say the telnet > keyboard part?
Some sort of event bus / pubsub with callbacks comes to mind, but is that a direction you want to look into, shall I try to put some effort in, let's say the telnet > keyboard part?
I have to admit I didn't think about this much when creating #24. Something like that was the idea, but I'm not quite sure whether it's the right choice. I have almost no experience with multithreaded programming, so I would like to check how other emulators do this before deciding what would the best way to implement this be.
Also I'm currently working on separating the telnet/socket code from the serial implementation, mainly because of sharing the code with a emulator console (in #12 it says "GUI", but a text console like the QEMU monitor would be better for now, since I haven't even decided on how exactly the GUI would work), so this isn't the ideal part to work on right now, since the code is going to change.
Some sort of event bus / pubsub with callbacks comes to mind, but is that a direction you want to look into, shall I try to put some effort in, let's say the telnet > keyboard part?
I have to admit I didn't think about this much when creating #24. Something like that was the idea, but I'm not quite sure whether it's the right choice. I have almost no experience with multithreaded programming, so I would like to check how other emulators do this before deciding what would the best way to implement this be.
At work I've written a few observer style multithreaded applications and the big coffee one is full of callbacks, to the point where it's very annoying to debug. IMHO they are great, but with great power comes great responsibility. Not everything needs to be a callback, but when you have a hammer, every problem is a nail...
Also I'm currently working on separating the telnet/socket code from the serial implementation, mainly because of sharing the code with a emulator console (in #12 it says "GUI", but a text console like the QEMU monitor would be better for now, since I haven't even decided on how exactly the GUI would work), so this isn't the ideal part to work on right now, since the code is going to change.
Okay thanks for letting me know. I'll save this branch for now.
Some tests without the delay (sleep removed) gave "unknown character" errors in the keyboard code during netbsd installation. Now that this delay is so low (you've lowered it already), is this bug stil relevant or will this be part of a bigger overhaul in #24?