mu
mu copied to clipboard
Reduce idle cpu consumtion (using the hlt instruction)
This is a feature request: Currently, when waiting for keyboard input, Mu uses a busy loop (which you can tell by the high CPU usage in qemu, for example in the shell app).
On x86, idling is pretty simple, by using the HLT instruction.
The issue here is that Mu doesn't use interrupts yet for the keyboard.. :thinking:
Ohh, I think I see what you mean! It looks like all my test programs continue to work if I just hlt
at the start of every call to read-key
! This is the low-level non-blocking primitive and it continues to not block (maybe due to the timer interrupt?) even when I animate say apps/hest-life.mu.
However, when I make this change, running the game of life inside the tiny screen in the shell (following the quickstart and then pressing ctrl+s
) slows down a lot. Does that sound right? This isn't insurmountable, I just need to adjust how frequently I check for a keypress when animating.
However, when I make this change, running the game of life inside the tiny screen in the shell (following the quickstart and then pressing ctrl+s) slows down a lot. Does that sound right? This isn't insurmountable, I just need to adjust how frequently I check for a keypress when animating.
You may need to adjust the PIT reload value. The BIOS default is the maximum, which generates a timer interrupt roughly every 55ms.