Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce idle cpu consumtion (using the hlt instruction) #53

Open
copy opened this issue Dec 8, 2023 · 3 comments · May be fixed by #54
Open

Reduce idle cpu consumtion (using the hlt instruction) #53

copy opened this issue Dec 8, 2023 · 3 comments · May be fixed by #54

Comments

@copy
Copy link

copy commented Dec 8, 2023

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.

@akkartik
Copy link
Owner

akkartik commented Dec 8, 2023

The issue here is that Mu doesn't use interrupts yet for the keyboard.. 🤔

@akkartik akkartik linked a pull request Dec 8, 2023 that will close this issue
@akkartik
Copy link
Owner

akkartik commented Dec 8, 2023

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.

@copy
Copy link
Author

copy commented Dec 8, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants